@@ -30,7 +30,7 @@ func TestWithPath(t *testing.T) {
3030 wantURL string
3131 }
3232
33- var tests = []test {
33+ tests : = []test {
3434 {
3535 "include_path false" ,
3636 testConfigReader {},
@@ -51,20 +51,22 @@ func TestWithPath(t *testing.T) {
5151 },
5252 }
5353
54- for _ , test := range tests {
55- r := & SpinRedirect {
56- cfg : & test .cfg ,
57- }
54+ for _ , tc := range tests {
55+ t .Run (tc .name , func (t * testing.T ) {
56+ r := & SpinRedirect {
57+ cfg : & tc .cfg ,
58+ }
5859
59- dest := "http://localhost"
60- req , err := http .NewRequest ("GET" , fmt .Sprintf ("http://localhost%s" , test .reqPath ), nil )
61- if err != nil {
62- t .Fatalf ("failed to create new http request: %s" , err . Error () )
63- }
60+ dest := "http://localhost"
61+ req , err := http .NewRequest ("GET" , fmt .Sprintf ("http://localhost%s" , tc .reqPath ), nil )
62+ if err != nil {
63+ t .Fatalf ("failed to create new http request: %s" , err )
64+ }
6465
65- gotURL := r .WithPath (dest , req )
66- if gotURL != test .wantURL {
67- t .Fatalf ("test '%s' failed: got '%s', want '%s'" , test .name , gotURL , test .wantURL )
68- }
66+ gotURL := r .WithPath (dest , req )
67+ if gotURL != tc .wantURL {
68+ t .Fatalf ("failed: got '%s', want '%s'" , gotURL , tc .wantURL )
69+ }
70+ })
6971 }
7072}
0 commit comments