Piotr Czajkowski 3 years ago
parent
commit
4af766b9ee
1 changed files with 6 additions and 14 deletions
  1. 6 14
      app_test.go

+ 6 - 14
app_test.go

@@ -6,23 +6,15 @@ import (
 )
 
 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
-	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)
+		}
 	}
 }