@@ -10,39 +10,43 @@ import (
10
10
)
11
11
12
12
func TestExecuteBaseHttp (t * testing.T ) {
13
- conf := dataplane.Configuration {
13
+ confOn := dataplane.Configuration {
14
14
BaseHTTPConfig : dataplane.BaseHTTPConfig {
15
15
HTTP2 : true ,
16
16
},
17
17
}
18
18
19
- g := NewWithT (t )
20
- expSubStrings := map [string ]int {
21
- "http2 on;" : 1 ,
22
- }
23
-
24
- for expSubStr , expCount := range expSubStrings {
25
- res := executeBaseHTTPConfig (conf )
26
- g .Expect (res ).To (HaveLen (1 ))
27
- g .Expect (expCount ).To (Equal (strings .Count (string (res [0 ].data ), expSubStr )))
28
- }
29
- }
30
-
31
- func TestExecuteBaseHttpEmpty (t * testing.T ) {
32
- conf := dataplane.Configuration {
19
+ confOff := dataplane.Configuration {
33
20
BaseHTTPConfig : dataplane.BaseHTTPConfig {
34
21
HTTP2 : false ,
35
22
},
36
23
}
37
24
38
- g := NewWithT (t )
39
- expSubStrings := map [string ]int {
40
- "http2 on;" : 0 ,
25
+ expSubStr := "http2 on;"
26
+
27
+ tests := []struct {
28
+ name string
29
+ conf dataplane.Configuration
30
+ expCount int
31
+ }{
32
+ {
33
+ name : "http2 on" ,
34
+ conf : confOn ,
35
+ expCount : 1 ,
36
+ },
37
+ {
38
+ name : "http2 off" ,
39
+ expCount : 0 ,
40
+ conf : confOff ,
41
+ },
41
42
}
42
43
43
- for expSubStr , expCount := range expSubStrings {
44
- res := executeBaseHTTPConfig (conf )
44
+ for _ , test := range tests {
45
+
46
+ g := NewWithT (t )
47
+
48
+ res := executeBaseHTTPConfig (test .conf )
45
49
g .Expect (res ).To (HaveLen (1 ))
46
- g .Expect (expCount ).To (Equal (strings .Count (string (res [0 ].data ), expSubStr )))
50
+ g .Expect (test . expCount ).To (Equal (strings .Count (string (res [0 ].data ), expSubStr )))
47
51
}
48
52
}
0 commit comments