-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspec.go
50 lines (44 loc) · 1.36 KB
/
spec.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
// 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 (
gdttypes "github.com./gdt-dev/gdt/types"
)
// Spec describes a test of a single HTTP request and response
type Spec struct {
gdttypes.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"`
// JSON payload to send along in request
Data interface{} `yaml:"data,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 gdttypes.Spec) {
s.Spec = b
}
func (s *Spec) Base() *gdttypes.Spec {
return &s.Spec
}