|
@@ -6,23 +6,15 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
func TestSetBaseURL(t *testing.T) {
|
|
func TestSetBaseURL(t *testing.T) {
|
|
- urlWithSlash := "http://test.com:880/test/"
|
|
|
|
- urlWithoutSlash := "http://test.com:880/test"
|
|
|
|
|
|
+ toTest := []string{"http://test.com:880/test/", "http://test.com:880/test"}
|
|
|
|
|
|
- t.Log("Testing if mandatory slash is added to the end of BaseURL.")
|
|
|
|
var app Application
|
|
var app Application
|
|
- app.setBaseURL(urlWithSlash)
|
|
|
|
- if strings.HasSuffix(app.BaseURL, "//") {
|
|
|
|
- t.Errorf("URL has been malformed: %v", app.BaseURL)
|
|
|
|
- } else {
|
|
|
|
- t.Log("URL with slash was set correctly!")
|
|
|
|
- }
|
|
|
|
|
|
|
|
- app.setBaseURL(urlWithoutSlash)
|
|
|
|
- if !strings.HasSuffix(app.BaseURL, "/") {
|
|
|
|
- t.Errorf("URL has been malformed: %v", app.BaseURL)
|
|
|
|
- } else {
|
|
|
|
- t.Log("URL without slash was set correctly!")
|
|
|
|
|
|
+ for _, testCase := range toTest {
|
|
|
|
+ app.setBaseURL(testCase)
|
|
|
|
+ if strings.HasSuffix(app.BaseURL, "//") || !strings.HasSuffix(app.BaseURL, "/") {
|
|
|
|
+ t.Errorf("URL has been malformed: %v", app.BaseURL)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|