-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders_test.go
More file actions
78 lines (69 loc) · 1.63 KB
/
headers_test.go
File metadata and controls
78 lines (69 loc) · 1.63 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
68
69
70
71
72
73
74
75
76
77
78
package restapi
import (
"testing"
"github.com/blugnu/test"
)
func TestHeaders(t *testing.T) {
// ARRANGE
testcases := []struct {
scenario string
exec func(t *testing.T)
}{
{scenario: "set",
exec: func(t *testing.T) {
// ARRANGE
sut := &Result{headers: headers{
"Canonical": "old value (a)",
"X-Canonicalised": "old value (b)",
}}
// ACT
_ = sut.WithHeader("Canonical", "new value (a)")
_ = sut.WithHeader("x-canonicalised", "new value (b)")
_ = sut.WithHeader("new-header", "value (c)")
// ASSERT
test.Map(t, sut.headers).Equals(headers{
"Canonical": "new value (a)",
"X-Canonicalised": "new value (b)",
"New-Header": "value (c)",
})
},
},
{scenario: "setAll",
exec: func(t *testing.T) {
// ARRANGE
sut := &Result{headers: headers{
"Canonical": "old value (a)",
"Canonicalised": "old value (b)",
}}
// ACT
_ = sut.WithHeaders(map[string]any{
"canonicalised": "new value (b)",
"new-header": "new value (c)",
})
// ASSERT
test.Map(t, sut.headers).Equals(headers{
"Canonical": "old value (a)",
"Canonicalised": "new value (b)",
"New-Header": "new value (c)",
})
},
},
{scenario: "setNonCanonical",
exec: func(t *testing.T) {
// ARRANGE
sut := &Result{headers: headers{}}
// ACT
_ = sut.WithNonCanonicalHeader("non-canonical", "value")
// ASSERT
test.Map(t, sut.headers).Equals(headers{
"non-canonical": "value",
})
},
},
}
for _, tc := range testcases {
t.Run(tc.scenario, func(t *testing.T) {
tc.exec(t)
})
}
}