From c791986143f1383f0a32f59d1913239bac51f93d Mon Sep 17 00:00:00 2001 From: Michael Engelhardt Date: Sat, 21 Nov 2020 04:07:38 +0100 Subject: [PATCH] add test --- config/web_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/config/web_test.go b/config/web_test.go index 9ab04b29..36333c9d 100644 --- a/config/web_test.go +++ b/config/web_test.go @@ -1,6 +1,9 @@ package config -import "testing" +import ( + "fmt" + "testing" +) func TestWebConfig_SocketAddress(t *testing.T) { web := &webConfig{ @@ -52,6 +55,18 @@ func TestWebConfig_ContextRootInvalid(t *testing.T) { t.Fatal("Should've panicked because the configuration specifies an invalid context root") } +func TestWebConfig_ContextRootNonParseable(t *testing.T) { + defer func() { recover() }() + + web := &webConfig{ + ContextRoot: "/invalid" + string([]byte{0x7F}) + "/", + } + + web.validateAndSetDefaults() + + t.Fatal(fmt.Sprintf("Should've panicked because the configuration specifies an invalid context root %s", web.ContextRoot)) +} + func TestWebConfig_ContextRootMultiPath(t *testing.T) { const expected = "/app/status/" web := &webConfig{