1package dns01
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/assert"
7)
8
9func TestToFqdn(t *testing.T) {
10	testCases := []struct {
11		desc     string
12		domain   string
13		expected string
14	}{
15		{
16			desc:     "simple",
17			domain:   "foo.bar.com",
18			expected: "foo.bar.com.",
19		},
20		{
21			desc:     "already FQDN",
22			domain:   "foo.bar.com.",
23			expected: "foo.bar.com.",
24		},
25	}
26
27	for _, test := range testCases {
28		test := test
29		t.Run(test.desc, func(t *testing.T) {
30			t.Parallel()
31
32			fqdn := ToFqdn(test.domain)
33			assert.Equal(t, test.expected, fqdn)
34		})
35	}
36}
37
38func TestUnFqdn(t *testing.T) {
39	testCases := []struct {
40		desc     string
41		fqdn     string
42		expected string
43	}{
44		{
45			desc:     "simple",
46			fqdn:     "foo.bar.com.",
47			expected: "foo.bar.com",
48		},
49		{
50			desc:     "already domain",
51			fqdn:     "foo.bar.com",
52			expected: "foo.bar.com",
53		},
54	}
55
56	for _, test := range testCases {
57		test := test
58		t.Run(test.desc, func(t *testing.T) {
59			t.Parallel()
60
61			domain := UnFqdn(test.fqdn)
62
63			assert.Equal(t, test.expected, domain)
64		})
65	}
66}
67