forked from infobloxopen/infoblox-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
object_manager_ext_attrs_def_test.go
95 lines (86 loc) · 2.83 KB
/
object_manager_ext_attrs_def_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
package ibclient
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Object Manager: EA definition", func() {
Describe("Create EA Definition", func() {
cmpType := "Docker"
tenantID := "01234567890abcdef01234567890abcdef"
comment := "Test Extensible Attribute"
flags := "CGV"
listValues := []EADefListValue{"True", "False"}
name := "TestEA"
eaType := "string"
allowedTypes := []string{"arecord", "aaarecord", "ptrrecord"}
ead := EADefinition{
Name: name,
Comment: comment,
Flags: flags,
ListValues: listValues,
Type: eaType,
AllowedObjectTypes: allowedTypes}
fakeRefReturn := "extensibleattributedef/ZG5zLm5ldHdvcmtfdmlldyQyMw:TestEA"
eadFakeConnector := &fakeConnector{
createObjectObj: NewEADefinition(ead),
resultObject: NewEADefinition(ead),
fakeRefReturn: fakeRefReturn,
}
eadFakeConnector.resultObject.(*EADefinition).Ref = fakeRefReturn
objMgr := NewObjectManager(eadFakeConnector, cmpType, tenantID)
var actualEADef *EADefinition
var err error
It("should pass expected EA Definintion Object to CreateObject", func() {
actualEADef, err = objMgr.CreateEADefinition(ead)
})
It("should return expected EA Definition Object", func() {
Expect(actualEADef).To(Equal(eadFakeConnector.resultObject))
Expect(err).To(BeNil())
})
})
Describe("Get EA Definition", func() {
cmpType := "Docker"
tenantID := "01234567890abcdef01234567890abcdef"
comment := "Test Extensible Attribute"
flags := "CGV"
listValues := []EADefListValue{"True", "False"}
name := "TestEA"
eaType := "string"
allowedTypes := []string{"arecord", "aaarecord", "ptrrecord"}
ead := EADefinition{
Name: name,
}
fakeRefReturn := "extensibleattributedef/ZG5zLm5ldHdvcmtfdmlldyQyMw:TestEA"
eadRes := EADefinition{
Name: name,
Comment: comment,
Flags: flags,
ListValues: listValues,
Type: eaType,
AllowedObjectTypes: allowedTypes,
Ref: fakeRefReturn,
}
queryParams := NewQueryParams(
false,
map[string]string{
"name": name,
})
eadFakeConnector := &fakeConnector{
getObjectObj: NewEADefinition(ead),
getObjectRef: "",
getObjectQueryParams: queryParams,
resultObject: []EADefinition{*NewEADefinition(eadRes)},
fakeRefReturn: fakeRefReturn,
}
objMgr := NewObjectManager(eadFakeConnector, cmpType, tenantID)
var actualEADef *EADefinition
var err error
It("should pass expected EA Definintion Object to GetObject", func() {
actualEADef, err = objMgr.GetEADefinition(name)
})
It("should return expected EA Definition Object", func() {
Expect(*actualEADef).To(Equal(eadFakeConnector.resultObject.([]EADefinition)[0]))
Expect(err).To(BeNil())
})
})
})