1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/pkg/model/settings_test.go
2014-03-07 13:21:43 -07:00

36 lines
953 B
Go

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)
}
}