app_test.go 756 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "strings"
  4. "testing"
  5. )
  6. func TestSetBaseURL(t *testing.T) {
  7. toTest := []string{"http://test.com:880/test/", "http://test.com:880/test"}
  8. var app Application
  9. for _, testCase := range toTest {
  10. app.setBaseURL(testCase)
  11. if strings.HasSuffix(app.BaseURL, "//") || !strings.HasSuffix(app.BaseURL, "/") {
  12. t.Errorf("URL has been malformed: %v", app.BaseURL)
  13. }
  14. }
  15. }
  16. func TestLoadLanguages(t *testing.T) {
  17. var app Application
  18. app.loadLanguages()
  19. testLanguageCode := "dan"
  20. testLanguage := "Danish"
  21. fromMap, ok := app.Languages[testLanguageCode]
  22. if !ok {
  23. t.Fatalf("There's no key '%v'!", testLanguageCode)
  24. }
  25. if fromMap != testLanguage {
  26. t.Fatalf("Value of key '%v' isn't '%v'", testLanguageCode, testLanguage)
  27. }
  28. }