@@ -29,111 +29,104 @@ var _ = Describe("Tag Unit Tests", func() {
29
29
})
30
30
31
31
Context ("Tag Integ Tests" , func () {
32
- client , connectionErr := cloud .NewClient ("../../cloud-config" )
33
-
34
32
BeforeEach (func () {
35
- if connectionErr != nil { // Only do these tests if an actual ACS instance is available via cloud-config.
36
- Skip ("Could not connect to ACS instance." )
37
- }
38
- if err := client .ResolveNetwork (& dummies .Net1 ); err != nil {
39
- Skip ("Could not find network." )
40
- }
33
+ client = realCloudClient
34
+ FetchIntegTestResources ()
41
35
42
- // Delete any existing tags
43
- existingTags , err := client .GetTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID )
36
+ existingTags , err := client .GetTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 .Spec .ID )
44
37
if err != nil {
45
38
Fail ("Failed to get existing tags. Error: " + err .Error ())
46
39
}
47
40
if len (existingTags ) > 0 {
48
- err = client .DeleteTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID , existingTags )
41
+ err = client .DeleteTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , existingTags )
49
42
if err != nil {
50
43
Fail ("Failed to delete existing tags. Error: " + err .Error ())
51
44
}
52
45
}
53
46
})
54
47
55
48
It ("adds and gets a resource tag" , func () {
56
- Ω (client .AddTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .Tags )).Should (Succeed ())
57
- Ω (client .GetTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Equal (dummies .Tags ))
49
+ Ω (client .AddTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .Tags )).Should (Succeed ())
50
+ Ω (client .GetTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Equal (dummies .Tags ))
58
51
})
59
52
60
53
It ("deletes a resource tag" , func () {
61
- Ω (client .AddTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .Tags )).Should (Succeed ())
62
- Ω (client .DeleteTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .Tags )).Should (Succeed ())
63
- Ω (client .GetTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Equal (map [string ]string {}))
54
+ Ω (client .AddTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .Tags )).Should (Succeed ())
55
+ Ω (client .DeleteTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .Tags )).Should (Succeed ())
56
+ Ω (client .GetTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Equal (map [string ]string {}))
64
57
})
65
58
66
59
It ("returns an error when you delete a tag that doesn't exist" , func () {
67
- Ω (client .DeleteTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .Tags )).Should (Succeed ())
60
+ Ω (client .DeleteTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .Tags )).Should (Succeed ())
68
61
})
69
62
70
63
It ("adds the tags for a cluster (resource created by CAPC)" , func () {
71
- Ω (client .AddCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).
64
+ Ω (client .AddCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).
72
65
Should (Succeed ())
73
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).
66
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).
74
67
Should (Succeed ())
75
68
76
69
// Verify tags
77
- tags , err := client .GetTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID )
70
+ tags , err := client .GetTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )
78
71
Ω (err ).ShouldNot (HaveOccurred ())
79
72
80
73
Ω (tags [dummies .CSClusterTagKey ]).Should (Equal (dummies .CSClusterTagVal ))
81
74
})
82
75
83
76
It ("does not fail when the cluster tags are added twice" , func () {
84
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
85
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
77
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
78
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
86
79
})
87
80
88
81
It ("doesn't adds the tags for a cluster (resource NOT created by CAPC)" , func () {
89
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
82
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
90
83
91
84
// Verify tags
92
- tags , err := client .GetTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID )
85
+ tags , err := client .GetTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )
93
86
Ω (err ).Should (BeNil ())
94
87
Ω (tags [dummies .CreatedByCapcKey ]).Should (Equal ("" ))
95
88
Ω (tags [dummies .CSClusterTagKey ]).Should (Equal ("" ))
96
89
})
97
90
98
91
It ("deletes a cluster tag" , func () {
99
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
100
- Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
92
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
93
+ Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
101
94
102
- Ω (client .GetTags (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).ShouldNot (HaveKey (dummies .CSClusterTagKey ))
95
+ Ω (client .GetTags (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).ShouldNot (HaveKey (dummies .CSClusterTagKey ))
103
96
})
104
97
105
98
It ("adds and deletes a created by capc tag" , func () {
106
- Ω (client .AddCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Succeed ())
107
- Ω (client .DeleteCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Succeed ())
99
+ Ω (client .AddCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Succeed ())
100
+ Ω (client .DeleteCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Succeed ())
108
101
})
109
102
110
103
It ("does not fail when cluster and CAPC created tags are deleted twice" , func () {
111
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
112
- Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
113
- Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
114
- Ω (client .DeleteCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Succeed ())
115
- Ω (client .DeleteCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Succeed ())
104
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
105
+ Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
106
+ Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
107
+ Ω (client .DeleteCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Succeed ())
108
+ Ω (client .DeleteCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Succeed ())
116
109
})
117
110
118
111
It ("does not allow a resource to be deleted when there are no tags" , func () {
119
- tagsAllowDisposal , err := client .DoClusterTagsAllowDisposal (cloud .ResourceTypeNetwork , dummies .Net1 .ID )
112
+ tagsAllowDisposal , err := client .DoClusterTagsAllowDisposal (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )
120
113
Ω (err ).Should (BeNil ())
121
114
Ω (tagsAllowDisposal ).Should (BeFalse ())
122
115
})
123
116
124
117
It ("does not allow a resource to be deleted when there is a cluster tag" , func () {
125
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
126
- tagsAllowDisposal , err := client .DoClusterTagsAllowDisposal (cloud .ResourceTypeNetwork , dummies .Net1 .ID )
118
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
119
+ tagsAllowDisposal , err := client .DoClusterTagsAllowDisposal (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )
127
120
Ω (err ).Should (BeNil ())
128
121
Ω (tagsAllowDisposal ).Should (BeFalse ())
129
122
})
130
123
131
124
It ("does allow a resource to be deleted when there are no cluster tags and there is a CAPC created tag" , func () {
132
- Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
133
- Ω (client .AddCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID )).Should (Succeed ())
134
- Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .Net1 .ID , dummies .CSCluster )).Should (Succeed ())
125
+ Ω (client .AddClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
126
+ Ω (client .AddCreatedByCAPCTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )).Should (Succeed ())
127
+ Ω (client .DeleteClusterTag (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID , dummies .CSCluster )).Should (Succeed ())
135
128
136
- tagsAllowDisposal , err := client .DoClusterTagsAllowDisposal (cloud .ResourceTypeNetwork , dummies .Net1 .ID )
129
+ tagsAllowDisposal , err := client .DoClusterTagsAllowDisposal (cloud .ResourceTypeNetwork , dummies .CSISONet1 . Spec .ID )
137
130
Ω (err ).Should (BeNil ())
138
131
Ω (tagsAllowDisposal ).Should (BeTrue ())
139
132
})
0 commit comments