forked from assay-it/blueprint-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuite.go
More file actions
82 lines (60 loc) · 2.42 KB
/
suite.go
File metadata and controls
82 lines (60 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
Here is an example of Behavior as a Code suite for testing of Serverless,
Microservices and other systems that rely on interface syntaxes and its
behaviors. The behavior is implemented as function of the form:
func TestAbc() assay.Arrow
where Abc is a unique name of test case. Each case declares cause-and-effect:
↣ "Given" specifies the communication context and the known state of the
expected behavior;
↣ "When" executes key actions about the interaction with remote component;
↣ "Then" observes output of remote component, validates its correctness and
outputs results.
assay.it evaluates suites and its functions sequentially one after another.
*/
/*
Package sample is a standard Golang declaration. It groups set of logically
related contracts.
*/
package sample
/*
Standard Golang import declaration.
However, assay.it restricts usage of some package.
Please check assay.it/doc/core for details of allowed packages.
We are constantly looking for your feedback, please open an issue to us.
*/
import (
//
// assay-it/sdk-go introduces pure functional and typesafe syntax to implement
// HTTP communication and Behavior as a Code suites.
"github.com/assay-it/sdk-go/assay"
"github.com/assay-it/sdk-go/http"
ƒ "github.com/assay-it/sdk-go/http/recv"
ø "github.com/assay-it/sdk-go/http/send"
)
/*
TestOk makes HTTP request and checks the quality of the response. This is simple
extample just validates that service is alive and responding with HTML document.
Let's look in depth on the anatomy
*/
func TestOk() assay.Arrow {
/*
SDK defines a rich techniques to hide the networking complexity using
higher-order-functions and its compositions. See https://assay.it/doc/core
for details about api.
http.Join lifts primitive protocol "modifiers" to higher-order suite.
*/
return http.Join(
// module ø (http/send) defines function to declare HTTP request.
// See the https://assay.it/doc/core for details about module ø.
// declares HTTP method and destination URL
ø.GET("https://assay.it"),
// module ƒ (http/recv) defines function to validate correctness of HTTP
// response. Each ƒ constrain might terminate execution of consequent ƒ's
// if it expectation fails. See the https://assay.it/doc/core for details
// about module ƒ.
// requires HTTP Status Code to be 200 OK
ƒ.Code(http.StatusOK),
// requires response content-type to be text/html
ƒ.Header("Content-Type").Is("text/html"),
)
}