-
Notifications
You must be signed in to change notification settings - Fork 2
/
meta_test.go
62 lines (60 loc) · 1.46 KB
/
meta_test.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
58
59
60
61
62
package spectest
import (
"net/http"
"testing"
)
func TestMetaReportFileName(t *testing.T) {
type fields struct {
ConsumerName string
Duration int64
Host string
Method string
Name string
Path string
ReportFileName string
StatusCode int
TestingTargetName string
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "get custom report file name",
fields: fields{
ReportFileName: "custom-report-file-name",
Method: http.MethodGet,
Path: "/api/v1/users",
},
want: "custom-report-file-name",
},
{
name: "get default report file name (it's a hash)",
fields: fields{
ReportFileName: "",
Method: http.MethodGet,
Path: "/api/v1/users",
},
want: "405834851_2166136261",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &Meta{
ConsumerName: tt.fields.ConsumerName,
Duration: tt.fields.Duration,
Host: tt.fields.Host,
Method: tt.fields.Method,
Name: tt.fields.Name,
Path: tt.fields.Path,
ReportFileName: tt.fields.ReportFileName,
StatusCode: tt.fields.StatusCode,
TestingTargetName: tt.fields.TestingTargetName,
}
if got := m.reportFileName(); got != tt.want {
t.Errorf("Meta.reportFileName() = %v, want %v", got, tt.want)
}
})
}
}