-
Notifications
You must be signed in to change notification settings - Fork 0
/
namespace_test.go
74 lines (66 loc) · 1.65 KB
/
namespace_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package epplib
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNamespace(t *testing.T) {
t.Parallel()
for ns, s := range namespaceToStringMap {
assert.Equal(t, ns, stringToNamespaceMap[s])
assert.Equal(t, s, ns.String())
}
for s, ns := range stringToNamespaceMap {
assert.Equal(t, s, namespaceToStringMap[ns])
assert.Equal(t, ns, NamespaceFromString(s))
}
assert.Equal(t, "", NamespaceUnknown.String())
assert.Equal(t, NamespaceUnknown, NamespaceFromString("unknown namespace"))
}
func TestNamespace_Types(t *testing.T) {
for _, tc := range []struct {
name string
namespaces Namespaces
isObjectNs bool
isExtensionNs bool
}{
{
name: "recognize object namespaces",
namespaces: Namespaces{
NamespaceIETFHost10,
NamespaceIETFContact10,
NamespaceIETFDomain10,
},
isObjectNs: true,
},
{
name: "recognize extension namespaces",
namespaces: Namespaces{
NamespaceIETFSecDNS10,
NamespaceIETFSecDNS11,
NamespaceIISEpp12,
NamespaceIISRegistryLock10,
},
isExtensionNs: true,
},
{
name: "recognize extensions with no special type",
namespaces: Namespaces{
NamespaceW3XSI,
NamespaceIETFEPP10,
NamespaceUnknown,
},
},
} {
t.Run(tc.name, func(t *testing.T) {
for _, ns := range tc.namespaces {
assert.Equal(t, tc.isObjectNs, ns.IsObjectNamespace())
assert.Equal(t, tc.isExtensionNs, ns.IsExtensionNamespace())
}
})
}
}
func TestNamespaces(t *testing.T) {
ns := Namespaces{NamespaceIETFHost10, NamespaceIETFDomain10}
assert.True(t, ns.HasNamespace(NamespaceIETFDomain10))
assert.False(t, ns.HasNamespace(NamespaceIETFContact10))
}