diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-02-03 15:33:17 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-02-03 15:33:17 -0800 |
commit | 9c4299720900fce52daedfce2314d31e92f7fe1d (patch) | |
tree | 2a67a75d71011d071910a4cb4216d45ee9d904c4 /config/config_test.go | |
parent | 78385a351e208feb183549c2fa854b302da0c690 (diff) |
Add support for base URLs with subfolders
Diffstat (limited to 'config/config_test.go')
-rw-r--r-- | config/config_test.go | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/config/config_test.go b/config/config_test.go index 4c01bc5..fbc7175 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -9,7 +9,26 @@ import ( "testing" ) -func TestGetCustomBaseURL(t *testing.T) { +func TestDebugModeOn(t *testing.T) { + os.Clearenv() + os.Setenv("DEBUG", "1") + cfg := NewConfig() + + if !cfg.HasDebugMode() { + t.Fatalf(`Unexpected debug mode value, got "%v"`, cfg.HasDebugMode()) + } +} + +func TestDebugModeOff(t *testing.T) { + os.Clearenv() + cfg := NewConfig() + + if cfg.HasDebugMode() { + t.Fatalf(`Unexpected debug mode value, got "%v"`, cfg.HasDebugMode()) + } +} + +func TestCustomBaseURL(t *testing.T) { os.Clearenv() os.Setenv("BASE_URL", "http://example.org") cfg := NewConfig() @@ -17,9 +36,17 @@ func TestGetCustomBaseURL(t *testing.T) { if cfg.BaseURL() != "http://example.org" { t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL()) } + + if cfg.RootURL() != "http://example.org" { + t.Fatalf(`Unexpected root URL, got "%s"`, cfg.RootURL()) + } + + if cfg.BasePath() != "" { + t.Fatalf(`Unexpected base path, got "%s"`, cfg.BasePath()) + } } -func TestGetCustomBaseURLWithTrailingSlash(t *testing.T) { +func TestCustomBaseURLWithTrailingSlash(t *testing.T) { os.Clearenv() os.Setenv("BASE_URL", "http://example.org/folder/") cfg := NewConfig() @@ -27,13 +54,29 @@ func TestGetCustomBaseURLWithTrailingSlash(t *testing.T) { if cfg.BaseURL() != "http://example.org/folder" { t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL()) } + + if cfg.RootURL() != "http://example.org" { + t.Fatalf(`Unexpected root URL, got "%s"`, cfg.BaseURL()) + } + + if cfg.BasePath() != "/folder" { + t.Fatalf(`Unexpected base path, got "%s"`, cfg.BasePath()) + } } -func TestGetDefaultBaseURL(t *testing.T) { +func TestDefaultBaseURL(t *testing.T) { os.Clearenv() cfg := NewConfig() if cfg.BaseURL() != "http://localhost" { t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL()) } + + if cfg.RootURL() != "http://localhost" { + t.Fatalf(`Unexpected root URL, got "%s"`, cfg.RootURL()) + } + + if cfg.BasePath() != "" { + t.Fatalf(`Unexpected base path, got "%s"`, cfg.BasePath()) + } } |