forked from imroc/req
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_test.go
47 lines (34 loc) · 904 Bytes
/
header_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
/*
GoLang code created by Jirawat Harnsiriwatanakit https://github.com/kazekim
*/
package req
import "testing"
func TestParseStruct(t *testing.T) {
type HeaderStruct struct {
UserAgent string `json:"User-Agent"`
Authorization string `json:"Authorization"`
}
h := HeaderStruct{
"V1.0.0",
"roc",
}
var header Header
header = ParseStruct(header, h)
if header["User-Agent"] != h.UserAgent && header["Authorization"] != h.Authorization {
t.Fatal("struct parser for header is not working")
}
}
func TestHeaderFromStruct(t *testing.T) {
type HeaderStruct struct {
UserAgent string `json:"User-Agent"`
Authorization string `json:"Authorization"`
}
h := HeaderStruct{
"V1.0.0",
"roc",
}
header := HeaderFromStruct(h)
if header["User-Agent"] != h.UserAgent && header["Authorization"] != h.Authorization {
t.Fatal("struct parser for header is not working")
}
}