Update env_test.go
This commit is contained in:
parent
c50d4e629a
commit
2b2566b801
1 changed files with 0 additions and 44 deletions
44
internal/env/env_test.go
vendored
44
internal/env/env_test.go
vendored
|
@ -54,47 +54,3 @@ func TestTimeZoneParser(t *testing.T) {
|
||||||
_, err = Parse()
|
_, err = Parse()
|
||||||
assert.Equal(t, err.Error(), "Key: 'Config.TimeZone' Error:Field validation for 'TimeZone' failed on the 'timezone' tag", "Validation should fail")
|
assert.Equal(t, err.Error(), "Key: 'Config.TimeZone' Error:Field validation for 'TimeZone' failed on the 'timezone' tag", "Validation should fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHealthcheckUrlParser(t *testing.T) {
|
|
||||||
key := "HEALTHCHECK_URL"
|
|
||||||
var err error
|
|
||||||
defer func() {
|
|
||||||
os.Unsetenv(key)
|
|
||||||
}()
|
|
||||||
|
|
||||||
os.Setenv(key, "https://example.com/")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err, nil, "Parsing should pass")
|
|
||||||
|
|
||||||
os.Setenv(key, "http://www.example.com/")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err, nil, "Parsing should pass")
|
|
||||||
|
|
||||||
os.Setenv(key, "https://example.com")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err.Error(), "Key: 'Config.HealthcheckURL' Error:Field validation for 'HealthcheckURL' failed on the 'endswith' tag", "Validation should fail")
|
|
||||||
|
|
||||||
os.Setenv(key, "abc")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err.Error(), "Key: 'Config.HealthcheckURL' Error:Field validation for 'HealthcheckURL' failed on the 'url' tag", "Validation should fail")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestShoutrrrParser(t *testing.T) {
|
|
||||||
key := "NOTIFICATION_URL"
|
|
||||||
var err error
|
|
||||||
defer func() {
|
|
||||||
os.Unsetenv(key)
|
|
||||||
}()
|
|
||||||
|
|
||||||
os.Setenv(key, "smtp://xxx@xxx.com:xxx@smtp.gmail.com:587/?from=xxx@xxx.com&to=xxx@xxx.com")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err, nil, "Parsing should pass")
|
|
||||||
|
|
||||||
os.Setenv(key, "https://example.com")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err.Error(), "Key: 'Config.NotificationURL' Error:Field validation for 'NotificationURL' failed on the 'shoutrrr' tag", "Validation should fail")
|
|
||||||
|
|
||||||
os.Setenv(key, "abc")
|
|
||||||
_, err = Parse()
|
|
||||||
assert.Equal(t, err.Error(), "Key: 'Config.NotificationURL' Error:Field validation for 'NotificationURL' failed on the 'shoutrrr' tag", "Validation should fail")
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue