@@ -36,7 +36,7 @@ import (
36
36
37
37
func TestHttpAction_CreateClientRequest (t * testing.T ) {
38
38
tests := []struct {
39
- description string
39
+ name string
40
40
url string
41
41
expectedUrl string
42
42
expectedMethod string
@@ -46,7 +46,7 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
46
46
wantedErr error
47
47
}{
48
48
{
49
- description : "Uploadpack: no changes when no options found" ,
49
+ name : "Uploadpack: no changes when no options found" ,
50
50
url : "https://sometarget/abc" ,
51
51
expectedUrl : "https://sometarget/abc/git-upload-pack" ,
52
52
expectedMethod : "POST" ,
@@ -56,7 +56,7 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
56
56
wantedErr : nil ,
57
57
},
58
58
{
59
- description : "UploadpackLs: no changes when no options found" ,
59
+ name : "UploadpackLs: no changes when no options found" ,
60
60
url : "https://sometarget/abc" ,
61
61
expectedUrl : "https://sometarget/abc/info/refs?service=git-upload-pack" ,
62
62
expectedMethod : "GET" ,
@@ -66,7 +66,7 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
66
66
wantedErr : nil ,
67
67
},
68
68
{
69
- description : "Receivepack: no changes when no options found" ,
69
+ name : "Receivepack: no changes when no options found" ,
70
70
url : "https://sometarget/abc" ,
71
71
expectedUrl : "https://sometarget/abc/git-receive-pack" ,
72
72
expectedMethod : "POST" ,
@@ -76,7 +76,7 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
76
76
wantedErr : nil ,
77
77
},
78
78
{
79
- description : "ReceivepackLs: no changes when no options found" ,
79
+ name : "ReceivepackLs: no changes when no options found" ,
80
80
url : "https://sometarget/abc" ,
81
81
expectedUrl : "https://sometarget/abc/info/refs?service=git-receive-pack" ,
82
82
expectedMethod : "GET" ,
@@ -86,7 +86,7 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
86
86
wantedErr : nil ,
87
87
},
88
88
{
89
- description : "override URL via options" ,
89
+ name : "override URL via options" ,
90
90
url : "https://initial-target/abc" ,
91
91
expectedUrl : "https://final-target/git-upload-pack" ,
92
92
expectedMethod : "POST" ,
@@ -98,7 +98,7 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
98
98
wantedErr : nil ,
99
99
},
100
100
{
101
- description : "error when no http.transport provided" ,
101
+ name : "error when no http.transport provided" ,
102
102
url : "https://initial-target/abc" ,
103
103
expectedUrl : "" ,
104
104
expectedMethod : "" ,
@@ -110,45 +110,47 @@ func TestHttpAction_CreateClientRequest(t *testing.T) {
110
110
}
111
111
112
112
for _ , tt := range tests {
113
- if tt .opts != nil {
114
- AddTransportOptions (tt .url , * tt .opts )
115
- }
116
-
117
- _ , req , err := createClientRequest (tt .url , tt .action , tt .transport )
118
- if tt .wantedErr != nil {
119
- if tt .wantedErr .Error () != err .Error () {
120
- t .Errorf ("%s: wanted: %v got: %v" , tt .description , tt .wantedErr , err )
113
+ t .Run (tt .name , func (t * testing.T ) {
114
+ if tt .opts != nil {
115
+ AddTransportOptions (tt .url , * tt .opts )
121
116
}
122
- } else {
123
- assert .Equal (t , req .URL .String (), tt .expectedUrl )
124
- assert .Equal (t , req .Method , tt .expectedMethod )
125
- }
126
-
127
- if tt .opts != nil {
128
- RemoveTransportOptions (tt .url )
129
- }
117
+
118
+ _ , req , err := createClientRequest (tt .url , tt .action , tt .transport )
119
+ if tt .wantedErr != nil {
120
+ if tt .wantedErr .Error () != err .Error () {
121
+ t .Errorf ("wanted: %v got: %v" , tt .wantedErr , err )
122
+ }
123
+ } else {
124
+ assert .Equal (t , req .URL .String (), tt .expectedUrl )
125
+ assert .Equal (t , req .Method , tt .expectedMethod )
126
+ }
127
+
128
+ if tt .opts != nil {
129
+ RemoveTransportOptions (tt .url )
130
+ }
131
+ })
130
132
}
131
133
}
132
134
133
135
func TestOptions (t * testing.T ) {
134
136
tests := []struct {
135
- description string
137
+ name string
136
138
registerOpts bool
137
139
url string
138
140
opts TransportOptions
139
141
expectOpts bool
140
142
expectedOpts * TransportOptions
141
143
}{
142
144
{
143
- description : "return registered option" ,
145
+ name : "return registered option" ,
144
146
registerOpts : true ,
145
147
url : "https://target/?123" ,
146
148
opts : TransportOptions {},
147
149
expectOpts : true ,
148
150
expectedOpts : & TransportOptions {},
149
151
},
150
152
{
151
- description : "match registered options" ,
153
+ name : "match registered options" ,
152
154
registerOpts : true ,
153
155
url : "https://target/?876" ,
154
156
opts : TransportOptions {
@@ -162,7 +164,7 @@ func TestOptions(t *testing.T) {
162
164
},
163
165
},
164
166
{
165
- description : "ignore when options not registered" ,
167
+ name : "ignore when options not registered" ,
166
168
registerOpts : false ,
167
169
url : "" ,
168
170
opts : TransportOptions {},
@@ -172,28 +174,30 @@ func TestOptions(t *testing.T) {
172
174
}
173
175
174
176
for _ , tt := range tests {
175
- if tt .registerOpts {
176
- AddTransportOptions (tt .url , tt .opts )
177
- }
178
-
179
- opts , found := transportOptions (tt .url )
180
- if tt .expectOpts != found {
181
- t .Errorf ("%s: wanted %v got %v" , tt .description , tt .expectOpts , found )
182
- }
183
-
184
- if tt .expectOpts {
185
- if reflect .DeepEqual (opts , * tt .expectedOpts ) {
186
- t .Errorf ("%s: wanted %v got %v" , tt .description , * tt .expectedOpts , opts )
177
+ t .Run (tt .name , func (t * testing.T ) {
178
+ if tt .registerOpts {
179
+ AddTransportOptions (tt .url , tt .opts )
180
+ }
181
+
182
+ opts , found := transportOptions (tt .url )
183
+ if tt .expectOpts != found {
184
+ t .Errorf ("%s: wanted %v got %v" , tt .name , tt .expectOpts , found )
187
185
}
188
- }
189
186
190
- if tt .registerOpts {
191
- RemoveTransportOptions (tt .url )
192
- }
187
+ if tt .expectOpts {
188
+ if reflect .DeepEqual (opts , * tt .expectedOpts ) {
189
+ t .Errorf ("%s: wanted %v got %v" , tt .name , * tt .expectedOpts , opts )
190
+ }
191
+ }
193
192
194
- if _ , found = transportOptions (tt .url ); found {
195
- t .Errorf ("%s: option for %s was not removed" , tt .description , tt .url )
196
- }
193
+ if tt .registerOpts {
194
+ RemoveTransportOptions (tt .url )
195
+ }
196
+
197
+ if _ , found = transportOptions (tt .url ); found {
198
+ t .Errorf ("%s: option for %s was not removed" , tt .name , tt .url )
199
+ }
200
+ })
197
201
}
198
202
}
199
203
0 commit comments