@@ -91,7 +91,7 @@ func TestApplyGMSAConfig(t *testing.T) {
91
91
cleanupInfo := & containerCleanupInfo {}
92
92
err := applyGMSAConfig (containerConfigWithGMSAAnnotation , createConfig , cleanupInfo )
93
93
94
- assert .Nil (t , err )
94
+ assert .NoError (t , err )
95
95
96
96
// the registry key should have been properly created
97
97
if assert .Equal (t , 1 , len (key .setStringValueArgs )) {
@@ -114,7 +114,7 @@ func TestApplyGMSAConfig(t *testing.T) {
114
114
cleanupInfo := & containerCleanupInfo {}
115
115
err := applyGMSAConfig (containerConfigWithGMSAAnnotation , createConfig , cleanupInfo )
116
116
117
- assert .Nil (t , err )
117
+ assert .NoError (t , err )
118
118
119
119
if assert .NotNil (t , createConfig .HostConfig ) && assert .Equal (t , 1 , len (createConfig .HostConfig .SecurityOpt )) {
120
120
secOpt := createConfig .HostConfig .SecurityOpt [0 ]
@@ -135,15 +135,15 @@ func TestApplyGMSAConfig(t *testing.T) {
135
135
136
136
err := applyGMSAConfig (containerConfigWithGMSAAnnotation , & dockertypes.ContainerCreateConfig {}, & containerCleanupInfo {})
137
137
138
- require .NotNil (t , err )
138
+ require .Error (t , err )
139
139
assert .Contains (t , err .Error (), "error when generating gMSA registry value name: unable to generate random string" )
140
140
})
141
141
t .Run ("if there's an error opening the registry key" , func (t * testing.T ) {
142
142
defer setRegistryCreateKeyFunc (t , & dummyRegistryKey {}, fmt .Errorf ("dummy error" ))()
143
143
144
144
err := applyGMSAConfig (containerConfigWithGMSAAnnotation , & dockertypes.ContainerCreateConfig {}, & containerCleanupInfo {})
145
145
146
- require .NotNil (t , err )
146
+ require .Error (t , err )
147
147
assert .Contains (t , err .Error (), "unable to open registry key" )
148
148
})
149
149
t .Run ("if there's an error writing to the registry key" , func (t * testing.T ) {
@@ -153,7 +153,7 @@ func TestApplyGMSAConfig(t *testing.T) {
153
153
154
154
err := applyGMSAConfig (containerConfigWithGMSAAnnotation , & dockertypes.ContainerCreateConfig {}, & containerCleanupInfo {})
155
155
156
- if assert .NotNil (t , err ) {
156
+ if assert .Error (t , err ) {
157
157
assert .Contains (t , err .Error (), "unable to write into registry value" )
158
158
}
159
159
assert .True (t , key .closed )
@@ -163,7 +163,7 @@ func TestApplyGMSAConfig(t *testing.T) {
163
163
164
164
err := applyGMSAConfig (& runtimeapi.ContainerConfig {}, createConfig , & containerCleanupInfo {})
165
165
166
- assert .Nil (t , err )
166
+ assert .NoError (t , err )
167
167
assert .Nil (t , createConfig .HostConfig )
168
168
})
169
169
}
@@ -178,7 +178,7 @@ func TestRemoveGMSARegistryValue(t *testing.T) {
178
178
179
179
err := removeGMSARegistryValue (cleanupInfoWithValue )
180
180
181
- assert .Nil (t , err )
181
+ assert .NoError (t , err )
182
182
183
183
// the registry key should have been properly deleted
184
184
if assert .Equal (t , 1 , len (key .deleteValueArgs )) {
@@ -191,7 +191,7 @@ func TestRemoveGMSARegistryValue(t *testing.T) {
191
191
192
192
err := removeGMSARegistryValue (cleanupInfoWithValue )
193
193
194
- require .NotNil (t , err )
194
+ require .Error (t , err )
195
195
assert .Contains (t , err .Error (), "unable to open registry key" )
196
196
})
197
197
t .Run ("if there's an error deleting from the registry key" , func (t * testing.T ) {
@@ -201,7 +201,7 @@ func TestRemoveGMSARegistryValue(t *testing.T) {
201
201
202
202
err := removeGMSARegistryValue (cleanupInfoWithValue )
203
203
204
- if assert .NotNil (t , err ) {
204
+ if assert .Error (t , err ) {
205
205
assert .Contains (t , err .Error (), "unable to remove registry value" )
206
206
}
207
207
assert .True (t , key .closed )
@@ -212,7 +212,7 @@ func TestRemoveGMSARegistryValue(t *testing.T) {
212
212
213
213
err := removeGMSARegistryValue (& containerCleanupInfo {})
214
214
215
- assert .Nil (t , err )
215
+ assert .NoError (t , err )
216
216
assert .Equal (t , 0 , len (key .deleteValueArgs ))
217
217
})
218
218
}
0 commit comments