-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnode_dns_config_test.go
106 lines (91 loc) · 2.74 KB
/
node_dns_config_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2019 Smart-Edge.com, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cce_test
import (
"strings"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
cce "github.com/open-ness/edgecontroller"
)
var _ = Describe("Join Entities: NodeDNSConfig", func() {
var (
ncfg *cce.NodeDNSConfig
)
BeforeEach(func() {
ncfg = &cce.NodeDNSConfig{
ID: "6c7eacb8-7b95-4541-940c-aa18a6204645",
NodeID: "48606c73-3905-47e0-864f-14bc7466f5bb",
DNSConfigID: "84c1f7b9-53e7-408e-9223-deab73befc54",
}
})
Describe("GetTableName", func() {
It(`Should return "nodes_dns_configs"`, func() {
Expect(ncfg.GetTableName()).To(Equal("nodes_dns_configs"))
})
})
Describe("GetID", func() {
It("Should return the ID", func() {
Expect(ncfg.GetID()).To(Equal(
"6c7eacb8-7b95-4541-940c-aa18a6204645"))
})
})
Describe("SetID", func() {
It("Should set and return the updated ID", func() {
By("Setting the ID")
ncfg.SetID("456")
By("Getting the updated ID")
Expect(ncfg.ID).To(Equal("456"))
})
})
Describe("GetNodeID", func() {
It("Should return the node ID", func() {
Expect(ncfg.GetNodeID()).To(Equal(
"48606c73-3905-47e0-864f-14bc7466f5bb"))
})
})
Describe("Validate", func() {
It("Should return an error if ID is not a UUID", func() {
ncfg.ID = "123"
Expect(ncfg.Validate()).To(MatchError("id not a valid uuid"))
})
It("Should return an error if NodeID is not a UUID", func() {
ncfg.NodeID = "123"
Expect(ncfg.Validate()).To(MatchError("node_id not a valid uuid"))
})
It("Should return an error if DNSConfigID is not a UUID", func() {
ncfg.DNSConfigID = "123"
Expect(ncfg.Validate()).To(MatchError(
"dns_config_id not a valid uuid"))
})
})
Describe("FilterFields", func() {
It("Should return the filterable fields", func() {
Expect(ncfg.FilterFields()).To(Equal([]string{
"node_id",
"dns_config_id",
}))
})
})
Describe("String", func() {
It("Should return the string value", func() {
Expect(ncfg.String()).To(Equal(strings.TrimSpace(`
NodeDNSConfig[
ID: 6c7eacb8-7b95-4541-940c-aa18a6204645
NodeID: 48606c73-3905-47e0-864f-14bc7466f5bb
DNSConfigID: 84c1f7b9-53e7-408e-9223-deab73befc54
]`,
)))
})
})
})