@@ -10,39 +10,43 @@ import (
1010)
1111
1212func TestExecuteBaseHttp (t * testing.T ) {
13- conf := dataplane.Configuration {
13+ confOn := dataplane.Configuration {
1414 BaseHTTPConfig : dataplane.BaseHTTPConfig {
1515 HTTP2 : true ,
1616 },
1717 }
1818
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 {
3320 BaseHTTPConfig : dataplane.BaseHTTPConfig {
3421 HTTP2 : false ,
3522 },
3623 }
3724
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+ },
4142 }
4243
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 )
4549 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 )))
4751 }
4852}
0 commit comments