lego/challenge/dns01/fqdn_test.go

65 lines
1 KiB
Go
Raw Normal View History

2019-03-11 16:56:48 +00:00
package dns01
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToFqdn(t *testing.T) {
testCases := []struct {
desc string
domain string
expected string
}{
{
desc: "simple",
2024-02-24 19:49:40 +00:00
domain: "foo.example.com",
expected: "foo.example.com.",
},
{
desc: "already FQDN",
2024-02-24 19:49:40 +00:00
domain: "foo.example.com.",
expected: "foo.example.com.",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
fqdn := ToFqdn(test.domain)
assert.Equal(t, test.expected, fqdn)
})
}
}
func TestUnFqdn(t *testing.T) {
testCases := []struct {
desc string
fqdn string
expected string
}{
{
desc: "simple",
2024-02-24 19:49:40 +00:00
fqdn: "foo.example.",
expected: "foo.example",
},
{
desc: "already domain",
2024-02-24 19:49:40 +00:00
fqdn: "foo.example",
expected: "foo.example",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
domain := UnFqdn(test.fqdn)
assert.Equal(t, test.expected, domain)
})
}
}