/
types.go
57 lines (49 loc) · 1.55 KB
/
types.go
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
package internal
//go:generate go-enum --file $GOFILE --marshal --names
/*
ENUM(
http
grpc
)
*/
type RequestType string
type Call struct {
Name string `yaml:"name,omitempty"`
Type RequestType `yaml:"type,omitempty"`
Body map[string]any `yaml:"body,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
ServiceHost string `yaml:"service-host,omitempty"`
Url string `yaml:"url,omitempty"`
Method string `yaml:"method,omitempty"`
WantStatus int `yaml:"want-status,omitempty"`
Exports []Export `yaml:"exports,omitempty"`
Asserts []Assert `yaml:"asserts,omitempty"`
Print bool `yaml:"print,omitempty"`
SkipVerify bool `yaml:"skip-verify,omitempty"`
FromImport *ImportedCall `yaml:"from-import,omitempty"`
}
func (c *Call) GetType() RequestType {
if c.Type == "" {
return RequestTypeHttp
}
return c.Type
}
type Sequence struct {
Vars map[string]any `yaml:"vars"`
Imports map[string]string `yaml:"imports"`
Calls []Call `yaml:"calls"`
path string `yaml:"-"`
importedCalls map[string]map[string]Call `yaml:"-"`
}
type Export struct {
JQ string `yaml:"jq,omitempty"`
As string `yaml:"as,omitempty"`
}
type Assert struct {
JQ string `yaml:"jq,omitempty"`
Expected any `yaml:"expected,omitempty"`
}
type ImportedCall struct {
Name string `yaml:"name"`
Call string `yaml:"call"`
}