Files
terraform-provider-unifi/internal/provider/validators/country_code_test.go
Mateusz Filipowicz a36940b019 feat: add country setting resource support with unifi_setting_country resource (#31)
* feat: add country setting resource support with `unifi_setting_country` resource

* linting
2025-02-27 02:56:07 +01:00

35 lines
746 B
Go

package validators
import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCountryCodeValidation(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
code string
validationFailed bool
}{
{"Poland", "PL", false},
{"United States", "US", false},
{"Empty", "", false},
{"Too long", "ABC", true},
{"Too short", "A", true},
{"Unknown", "WP", true},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := countryCodeAlpha2Validator{}
req, resp := newStringValidatorRequestResponse(tc.code)
v.ValidateString(context.Background(), req, resp)
assert.Equal(t, tc.validationFailed, resp.Diagnostics.HasError())
})
}
}