github.com/marinho/drone@v0.2.1-0.20140504195434-d3ba962e89a7/pkg/model/settings_test.go (about) 1 package model 2 3 import ( 4 "testing" 5 ) 6 7 func Test_SettingsValidate(t *testing.T) { 8 settings := Settings{} 9 settings.GitHubApiUrl = "https://github.com/url/with/slash/" 10 if err := settings.Validate(); err != ErrInvalidGitHubTrailingSlash { 11 t.Errorf("Expecting ErrInvalidGitHubTrailingSlash") 12 } 13 14 settings = Settings{} 15 settings.SmtpServer = "127.1.1.1" 16 if err := settings.Validate(); err != ErrInvalidSmtpPort { 17 t.Errorf("Expecting ErrInvalidSmtpPort") 18 } 19 20 settings = Settings{} 21 settings.SmtpServer = "127.1.1.1" 22 settings.SmtpPort = "553" 23 if err := settings.Validate(); err != ErrInvalidSmtpAddress { 24 t.Errorf("Expecting ErrInvalidSmtpAddress") 25 } 26 27 settings = Settings{} 28 settings.SmtpServer = "127.1.1.1" 29 settings.SmtpPort = "553" 30 settings.SmtpAddress = "test@localhost" 31 settings.GitHubApiUrl = "https://api.github.com" 32 if err := settings.Validate(); err != nil { 33 t.Errorf("Expecting successful Settings validation, got %s", err) 34 } 35 }