-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf_test.go
55 lines (45 loc) · 1.33 KB
/
conf_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
package main
import (
"testing"
)
// Tests normal parsing of the configuration, and asserts that the
// correct nodes are returned etc. Doesn't test all nodes.
func TestParse(t *testing.T) {
// TODO: test parsing, validation, etc.
}
// Tests the splitting of headers and such.
func TestHeaders(t *testing.T) {
type Exp struct {
FullHeader Header
ExpectedName string
ExpectedValue string
}
tests := []Exp{
{"SOAPAction: http://www.example.org/bogus/soapaction", "SOAPAction", "http://www.example.org/bogus/soapaction"},
{"Content-Type: text/xml", "Content-Type", "text/xml"},
{"Content-Type:application/json", "Content-Type", "application/json"},
{"Content-Length: 22222", "Content-Length", "22222"},
}
for _, test := range tests {
pn := test.FullHeader.GetName()
pv := test.FullHeader.GetValue()
if pn != test.ExpectedName {
t.Errorf("expected '%s', got '%s'!", test.ExpectedName, pn)
}
if pv != test.ExpectedValue {
t.Errorf("expected '%s', got '%s'!", test.ExpectedValue, pv)
}
}
}
func TestHeaderValidate(t *testing.T) {
header := Header("Header no colon")
err := header.Validate()
if err == nil {
t.Errorf("expected error on header '%s'", header)
}
header = Header("Name with space: some value")
err = header.Validate()
if err == nil {
t.Errorf("expected error on header '%s'", header)
}
}