diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-07-03 15:21:56 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2026-07-03 15:21:58 +0200 |
| commit | 95dc66cb108a311065917362a00b86c08767303d (patch) | |
| tree | 46ca65be6548224be0dd5a42bb86f2ecede14da8 /provider/names_test.go | |
Diffstat (limited to 'provider/names_test.go')
| -rw-r--r-- | provider/names_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/provider/names_test.go b/provider/names_test.go new file mode 100644 index 0000000..ee2dd86 --- /dev/null +++ b/provider/names_test.go @@ -0,0 +1,37 @@ +package provider + +import "testing" + +func TestFqdn(t *testing.T) { + cases := []struct { + name, domain, want string + }{ + {"www", "example.com", "www.example.com"}, + {"", "example.com", "example.com"}, + {"*", "example.com", "*.example.com"}, + {"a.b", "example.com", "a.b.example.com"}, + } + for _, c := range cases { + if got := fqdn(c.name, c.domain); got != c.want { + t.Errorf("fqdn(%q, %q) = %q, want %q", c.name, c.domain, got, c.want) + } + } +} + +func TestSubdomain(t *testing.T) { + cases := []struct { + fullName, domain, want string + }{ + {"www.example.com", "example.com", "www"}, + {"example.com", "example.com", ""}, + {"WWW.EXAMPLE.COM", "example.com", "www"}, + {"www.example.com.", "example.com", "www"}, + {"a.b.example.com", "example.com", "a.b"}, + {"*.example.com", "example.com", "*"}, + } + for _, c := range cases { + if got := subdomain(c.fullName, c.domain); got != c.want { + t.Errorf("subdomain(%q, %q) = %q, want %q", c.fullName, c.domain, got, c.want) + } + } +} |