From 2e528dea246d26478b8e585f8d6f6ab25bb1f93c Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 7 Mar 2014 13:21:43 -0700 Subject: [PATCH] added unit tests for settings validation --- pkg/model/settings_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pkg/model/settings_test.go diff --git a/pkg/model/settings_test.go b/pkg/model/settings_test.go new file mode 100644 index 00000000..79c6f1e7 --- /dev/null +++ b/pkg/model/settings_test.go @@ -0,0 +1,35 @@ +package model + +import ( + "testing" +) + +func Test_SettingsValidate(t *testing.T) { + settings := Settings{} + settings.GitHubApiUrl = "https://github.com/url/with/slash/" + if err := settings.Validate(); err != ErrInvalidGitHubTrailingSlash { + t.Errorf("Expecting ErrInvalidGitHubTrailingSlash") + } + + settings = Settings{} + settings.SmtpServer = "127.1.1.1" + if err := settings.Validate(); err != ErrInvalidSmtpPort { + t.Errorf("Expecting ErrInvalidSmtpPort") + } + + settings = Settings{} + settings.SmtpServer = "127.1.1.1" + settings.SmtpPort = "553" + if err := settings.Validate(); err != ErrInvalidSmtpAddress { + t.Errorf("Expecting ErrInvalidSmtpAddress") + } + + settings = Settings{} + settings.SmtpServer = "127.1.1.1" + settings.SmtpPort = "553" + settings.SmtpAddress = "test@localhost" + settings.GitHubApiUrl = "https://api.github.com" + if err := settings.Validate(); err != nil { + t.Errorf("Expecting successful Settings validation, got %s", err) + } +}