Update env_test.go

This commit is contained in:
Florian Hoss 2023-06-21 17:25:59 +02:00
parent c50d4e629a
commit 2b2566b801

View file

@ -54,47 +54,3 @@ func TestTimeZoneParser(t *testing.T) {
_, err = Parse()
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")
}