added unit tests for settings validation
This commit is contained in:
parent
1348f8f5fc
commit
2e528dea24
1 changed files with 35 additions and 0 deletions
35
pkg/model/settings_test.go
Normal file
35
pkg/model/settings_test.go
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue