-
Notifications
You must be signed in to change notification settings - Fork 0
/
producer_contract_request.go
41 lines (37 loc) · 1.24 KB
/
producer_contract_request.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
package types
// ProducerContractRequest for generating fuzz-data requests to an API implementation for producer based contract testing
type ProducerContractRequest struct {
// BaseURL of remote server
BaseURL string `yaml:"base_url" json:"base_url"`
// ExecutionTimes for contract testing
ExecutionTimes int `yaml:"execution_times" json:"execution_times"`
// Verbose setting
Verbose bool `yaml:"verbose" json:"verbose"`
// Headers overrides
Headers map[string][]string `yaml:"-" json:"-"`
// Params local overrides
Params map[string]any `yaml:"-" json:"-"`
}
// NewProducerContractRequest constructor
func NewProducerContractRequest(baseURL string, execTimes int) *ProducerContractRequest {
return &ProducerContractRequest{
BaseURL: baseURL,
ExecutionTimes: execTimes,
Headers: make(map[string][]string),
Params: make(map[string]any),
}
}
// Overrides helper methods to aggregate headers and params
func (req *ProducerContractRequest) Overrides() map[string]any {
res := make(map[string]any)
for k, v := range req.Headers {
res[k] = v[0]
}
for k, v := range req.Params {
res[k] = v
}
return res
}
func (req *ProducerContractRequest) String() string {
return "ProducerContractRequest(" + req.BaseURL + ")"
}