-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
44 lines (38 loc) · 1.31 KB
/
model.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
package httpbacktest
import (
"encoding/json"
"github.com/go-resty/resty/v2"
"go.uber.org/ratelimit"
)
type Client struct {
http *resty.Client
rl ratelimit.Limiter
}
func NewHttpBacktestClient(requestPerSecond int) *Client {
return &Client{
http: resty.New(),
rl: ratelimit.New(requestPerSecond),
}
}
type Result struct {
Name string `json:"name"`
TotalRequests int `json:"totalRequests"`
UniqueURLs int `json:"uniqueURLs"`
StatusMatched int `json:"statusMatched"`
StatusNoMatched int `json:"statusNoMatched"`
StatusCodeSimilarity string `json:"statusCodeSimilarity"`
BodyMatched int `json:"bodyMatched"`
BodyNoMatched int `json:"bodyNoMatched"`
BodySimilarity string `json:"bodySimilarity"`
BodyEquivalent map[string]int `json:"bodyEquivalent"`
EnvironmentDetailsA EnvironmentDetails `json:"environmentDetailsA"`
EnvironmentDetailsB EnvironmentDetails `json:"environmentDetailsB"`
}
func (r Result) JSON() string {
b, _ := json.Marshal(r)
return string(b)
}
type EnvironmentDetails struct {
Errors []error `json:"errors,omitempty"`
StatusCodes map[int]int `json:"stagingStatusCodes"`
}