forked from tufanbarisyildirim/gonginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirective_test.go
96 lines (94 loc) · 1.68 KB
/
directive_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package gonginx
import (
"testing"
)
func TestDirective_ToString(t *testing.T) {
t.Parallel()
type fields struct {
Name string
Parameters []string
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "server_name direction",
fields: fields{
Name: "server_name",
Parameters: []string{
"gonginx.dev",
"gonginx.local",
"microspector.com",
},
},
want: "server_name gonginx.dev gonginx.local microspector.com;",
},
{
name: "proxy_pass direction",
fields: fields{
Name: "proxy_pass",
Parameters: []string{
"http://127.0.0.1/",
},
},
want: "proxy_pass http://127.0.0.1/;",
},
{
name: "proxy_set_header direction",
fields: fields{
Name: "proxy_set_header",
Parameters: []string{
"Host",
"$host",
},
},
want: "proxy_set_header Host $host;",
},
{
name: "proxy_buffers direction",
fields: fields{
Name: "proxy_buffers",
Parameters: []string{
"4",
"32k",
},
},
want: "proxy_buffers 4 32k;",
},
{
name: "charset direction",
fields: fields{
Name: "charset",
Parameters: []string{
"koi8-r",
},
},
want: "charset koi8-r;",
},
{
name: "'' close",
fields: fields{
Name: "''",
Parameters: []string{
"close",
},
},
want: "'' close;",
},
}
for _, tt := range tests {
tt2 := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
d := &Directive{
Name: tt2.fields.Name,
Parameters: tt2.fields.Parameters,
}
if got := DumpDirective(d, NoIndentStyle); got != tt2.want {
t.Errorf("Directive.ToString() = %v, want %v", got, tt2.want)
}
})
}
}