forked from gdt-dev/http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec.go
More file actions
67 lines (58 loc) · 1.92 KB
/
spec.go
File metadata and controls
67 lines (58 loc) · 1.92 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
// Use and distribution licensed under the Apache license version 2.
//
// See the COPYING file in the root project directory for full text.
package http
import (
api "github.com/gdt-dev/gdt/api"
)
// Capture describes how to capture response values into variables using JSONPath
type Capture map[string]string
// Spec describes a test of a single HTTP request and response
type Spec struct {
api.Spec
// URL being called by HTTP client
URL string `yaml:"url,omitempty"`
// HTTP Method specified by HTTP client
Method string `yaml:"method,omitempty"`
// Shortcut for URL and Method of "GET"
GET string `yaml:"GET,omitempty"`
// Shortcut for URL and Method of "POST"
POST string `yaml:"POST,omitempty"`
// Shortcut for URL and Method of "PUT"
PUT string `yaml:"PUT,omitempty"`
// Shortcut for URL and Method of "PATCH"
PATCH string `yaml:"PATCH,omitempty"`
// Shortcut for URL and Method of "DELETE"
DELETE string `yaml:"DELETE,omitempty"`
// Headers contains HTTP headers to be sent with the request
Headers map[string]string `yaml:"headers,omitempty"`
// JSON payload to send along in request
Data interface{} `yaml:"data,omitempty"`
// Capture contains JSONPath expressions to extract values from response
Capture Capture `yaml:"capture,omitempty"`
// Assert is the assertions for the HTTP response
Assert *Expect `yaml:"assert,omitempty"`
}
// Title returns a good name for the Spec
func (s *Spec) Title() string {
// If the user did not specify a name for the test spec, just default
// it to the method and URL
if s.Name != "" {
return s.Name
}
return s.Method + ":" + s.URL
}
func (s *Spec) SetBase(b api.Spec) {
s.Spec = b
}
func (s *Spec) Base() *api.Spec {
return &s.Spec
}
// Retry returns the Evaluable's Retry override, if any
func (s *Spec) Retry() *api.Retry {
return s.Spec.Retry
}
// Timeout returns the Evaluable's Timeout override, if any
func (s *Spec) Timeout() *api.Timeout {
return s.Spec.Timeout
}