-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_params_test.go
38 lines (34 loc) · 954 Bytes
/
request_params_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
package navaros_test
import (
"testing"
"github.com/RobertWHurst/navaros"
)
func TestRequestParamsGet(t *testing.T) {
cases := []struct {
message string
params navaros.RequestParams
key string
expectedValue string
}{
{"should return the value for a key that exists",
navaros.RequestParams{"Content-Type": "application/json"},
"Content-Type", "application/json",
},
{"should return the value for a key that exists with different casing",
navaros.RequestParams{"Content-Type": "application/json"},
"content-type", "application/json",
},
{"should return an empty string for a key that does not exist",
navaros.RequestParams{"Content-Type": "application/json"},
"Accept", "",
},
}
for _, c := range cases {
t.Run(c.message, func(t *testing.T) {
value := c.params.Get(c.key)
if value != c.expectedValue {
t.Errorf("expected %s, got %s", c.expectedValue, value)
}
})
}
}