start working on context root configuration

This commit is contained in:
Michael Engelhardt committed 2020-11-21 02:33:02 +01:00
1 parent 76d45d7eb8
commit f9706a98ed
6 files changed
+126 -9

No files matched your search

+65
View File
@@ -11,3 +11,68 @@ func TestWebConfig_SocketAddress(t *testing.T) {
t.Errorf("expected %s, got %s", "0.0.0.0:8081", web.SocketAddress())
}
}
func TestWebConfig_ContextRoot(t *testing.T) {
const expected = "/status/"
web := &webConfig{
ContextRoot: "/status/",
}
web.validateAndSetDefaults()
if web.CtxRoot() != expected {
t.Errorf("expected %s, got %s", expected, web.CtxRoot())
}
}
func TestWebConfig_ContextRootWithEscapableChars(t *testing.T) {
const expected = "/s%3F=ta%20t%20u&s/"
web := &webConfig{
ContextRoot: "/s?=ta t u&s/",
}
web.validateAndSetDefaults()
if web.CtxRoot() != expected {
t.Errorf("expected %s, got %s", expected, web.CtxRoot())
}
}
func TestWebConfig_ContextRootMultiPath(t *testing.T) {
const expected = "/app/status"
web := &webConfig{
ContextRoot: "/app/status",
}
web.validateAndSetDefaults()
if web.CtxRoot() != expected {
t.Errorf("expected %s, got %s", expected, web.CtxRoot())
}
}
func TestWebConfig_ContextRootAppendWithEmptyContextRoot(t *testing.T) {
const expected = "/bla/"
web := &webConfig{}
web.validateAndSetDefaults()
if web.AppendToCtxRoot("/bla/") != expected {
t.Errorf("expected %s, got %s", expected, web.AppendToCtxRoot("/bla/"))
}
}
func TestWebConfig_ContextRootAppendWithContext(t *testing.T) {
const expected = "/app/status/bla/"
web := &webConfig{
ContextRoot: "/app/status",
}
web.validateAndSetDefaults()
if web.AppendToCtxRoot("/bla/") != expected {
t.Errorf("expected %s, got %s", expected, web.AppendToCtxRoot("/bla/"))
}
}