nginx-proxy-manager-zh/backend/internal/dnsproviders/common_test.go
2023-08-01 08:19:58 +10:00

34 lines
852 B
Go

package dnsproviders
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetAll(t *testing.T) {
providers := GetAll()
// This number will have to (annoyingly) be updated
// when adding new dns providers to the list
assert.Equal(t, 45, len(providers))
_, dynuExists := providers["dns_dynu"]
assert.Equal(t, true, dynuExists)
_, duckDNSExists := providers["dns_duckdns"]
assert.Equal(t, true, duckDNSExists)
_, cfExists := providers["dns_cf"]
assert.Equal(t, true, cfExists)
_, randomExists := providers["dns_shouldnotexist"]
assert.Equal(t, false, randomExists)
}
func TestGet(t *testing.T) {
provider, err := Get("dns_duckdns")
assert.Nil(t, err)
assert.Equal(t, "dns_duckdns", provider.Title)
provider, err = Get("dns_shouldnotexist")
assert.NotNil(t, err)
assert.Equal(t, "provider_not_found", err.Error())
}