From 3d80bc801bb034e17cae38591335b3b1110f1c47 Mon Sep 17 00:00:00 2001 From: kanozec <30459655+kanozec@users.noreply.github.com> Date: Tue, 30 Oct 2018 23:25:28 +0800 Subject: [PATCH] Use subtests in mux_test.go (#415) --- mux_test.go | 117 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 41 deletions(-) diff --git a/mux_test.go b/mux_test.go index 31c7d51..5d4027e 100644 --- a/mux_test.go +++ b/mux_test.go @@ -205,8 +205,10 @@ func TestHost(t *testing.T) { }, } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + }) } } @@ -437,10 +439,12 @@ func TestPath(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testUseEscapedRoute(t, test) - testRegexp(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + testUseEscapedRoute(t, test) + testRegexp(t, test) + }) } } @@ -516,9 +520,11 @@ func TestPathPrefix(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testUseEscapedRoute(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + testUseEscapedRoute(t, test) + }) } } @@ -623,9 +629,11 @@ func TestSchemeHostPath(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testUseEscapedRoute(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + testUseEscapedRoute(t, test) + }) } } @@ -682,8 +690,10 @@ func TestHeaders(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + }) } } @@ -732,9 +742,11 @@ func TestMethods(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testMethods(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + testMethods(t, test) + }) } } @@ -1039,11 +1051,12 @@ func TestQueries(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testQueriesTemplates(t, test) - testUseEscapedRoute(t, test) - testQueriesRegexp(t, test) + t.Run(test.title, func(t *testing.T) { + testTemplate(t, test) + testQueriesTemplates(t, test) + testUseEscapedRoute(t, test) + testQueriesRegexp(t, test) + }) } } @@ -1092,8 +1105,10 @@ func TestSchemes(t *testing.T) { }, } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + }) } } @@ -1127,8 +1142,10 @@ func TestMatcherFunc(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + }) } } @@ -1163,8 +1180,10 @@ func TestBuildVarsFunc(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + }) } } @@ -1294,9 +1313,11 @@ func TestSubRouter(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testUseEscapedRoute(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + testUseEscapedRoute(t, test) + }) } } @@ -1400,9 +1421,11 @@ func TestStrictSlash(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) - testUseEscapedRoute(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + testUseEscapedRoute(t, test) + }) } } @@ -1434,8 +1457,10 @@ func TestUseEncodedPath(t *testing.T) { } for _, test := range tests { - testRoute(t, test) - testTemplate(t, test) + t.Run(test.title, func(t *testing.T) { + testRoute(t, test) + testTemplate(t, test) + }) } } @@ -2040,7 +2065,9 @@ func TestMethodsSubrouterCatchall(t *testing.T) { } for _, test := range tests { - testMethodsSubrouter(t, test) + t.Run(test.title, func(t *testing.T) { + testMethodsSubrouter(t, test) + }) } } @@ -2096,7 +2123,9 @@ func TestMethodsSubrouterStrictSlash(t *testing.T) { } for _, test := range tests { - testMethodsSubrouter(t, test) + t.Run(test.title, func(t *testing.T) { + testMethodsSubrouter(t, test) + }) } } @@ -2143,7 +2172,9 @@ func TestMethodsSubrouterPathPrefix(t *testing.T) { } for _, test := range tests { - testMethodsSubrouter(t, test) + t.Run(test.title, func(t *testing.T) { + testMethodsSubrouter(t, test) + }) } } @@ -2199,7 +2230,9 @@ func TestMethodsSubrouterSubrouter(t *testing.T) { } for _, test := range tests { - testMethodsSubrouter(t, test) + t.Run(test.title, func(t *testing.T) { + testMethodsSubrouter(t, test) + }) } } @@ -2253,7 +2286,9 @@ func TestMethodsSubrouterPathVariable(t *testing.T) { } for _, test := range tests { - testMethodsSubrouter(t, test) + t.Run(test.title, func(t *testing.T) { + testMethodsSubrouter(t, test) + }) } }