4
4
"context"
5
5
"encoding/json"
6
6
"errors"
7
- "fmt"
8
7
"net/http"
9
8
"net/http/httptest"
10
9
"reflect"
@@ -107,7 +106,7 @@ func TestSyncValidate(t *testing.T) {
107
106
108
107
func TestSyncNotPermittedNamespace (t * testing.T ) {
109
108
syncCtx := newTestSyncCtx (nil , WithPermissionValidator (func (_ * unstructured.Unstructured , _ * v1.APIResource ) error {
110
- return fmt . Errorf ("not permitted in project" )
109
+ return errors . New ("not permitted in project" )
111
110
}))
112
111
targetPod := NewPod ()
113
112
targetPod .SetNamespace ("kube-system" )
@@ -307,7 +306,7 @@ func TestSyncCreateFailure(t *testing.T) {
307
306
Commands : map [string ]kubetest.KubectlOutput {
308
307
testSvc .GetName (): {
309
308
Output : "" ,
310
- Err : fmt . Errorf ("foo" ),
309
+ Err : errors . New ("foo" ),
311
310
},
312
311
},
313
312
}
@@ -316,7 +315,7 @@ func TestSyncCreateFailure(t *testing.T) {
316
315
Commands : map [string ]kubetest.KubectlOutput {
317
316
testSvc .GetName (): {
318
317
Output : "" ,
319
- Err : fmt . Errorf ("foo" ),
318
+ Err : errors . New ("foo" ),
320
319
},
321
320
},
322
321
}
@@ -457,7 +456,7 @@ func TestSyncPruneFailure(t *testing.T) {
457
456
Commands : map [string ]kubetest.KubectlOutput {
458
457
"test-service" : {
459
458
Output : "" ,
460
- Err : fmt . Errorf ("foo" ),
459
+ Err : errors . New ("foo" ),
461
460
},
462
461
},
463
462
}
@@ -466,7 +465,7 @@ func TestSyncPruneFailure(t *testing.T) {
466
465
Commands : map [string ]kubetest.KubectlOutput {
467
466
"test-service" : {
468
467
Output : "" ,
469
- Err : fmt . Errorf ("foo" ),
468
+ Err : errors . New ("foo" ),
470
469
},
471
470
},
472
471
}
@@ -1195,11 +1194,11 @@ func TestSyncFailureHookWithFailedSync(t *testing.T) {
1195
1194
})
1196
1195
syncCtx .hooks = []* unstructured.Unstructured {newHook (synccommon .HookTypeSyncFail )}
1197
1196
mockKubectl := & kubetest.MockKubectlCmd {
1198
- Commands : map [string ]kubetest.KubectlOutput {pod .GetName (): {Err : fmt . Errorf ("" )}},
1197
+ Commands : map [string ]kubetest.KubectlOutput {pod .GetName (): {Err : errors . New ("" )}},
1199
1198
}
1200
1199
syncCtx .kubectl = mockKubectl
1201
1200
mockResourceOps := kubetest.MockResourceOps {
1202
- Commands : map [string ]kubetest.KubectlOutput {pod .GetName (): {Err : fmt . Errorf ("" )}},
1201
+ Commands : map [string ]kubetest.KubectlOutput {pod .GetName (): {Err : errors . New ("" )}},
1203
1202
}
1204
1203
syncCtx .resourceOps = & mockResourceOps
1205
1204
@@ -1248,18 +1247,18 @@ func TestRunSyncFailHooksFailed(t *testing.T) {
1248
1247
mockKubectl := & kubetest.MockKubectlCmd {
1249
1248
Commands : map [string ]kubetest.KubectlOutput {
1250
1249
// Fail operation
1251
- pod .GetName (): {Err : fmt . Errorf ("" )},
1250
+ pod .GetName (): {Err : errors . New ("" )},
1252
1251
// Fail a single SyncFail hook
1253
- failedSyncFailHook .GetName (): {Err : fmt . Errorf ("" )},
1252
+ failedSyncFailHook .GetName (): {Err : errors . New ("" )},
1254
1253
},
1255
1254
}
1256
1255
syncCtx .kubectl = mockKubectl
1257
1256
mockResourceOps := kubetest.MockResourceOps {
1258
1257
Commands : map [string ]kubetest.KubectlOutput {
1259
1258
// Fail operation
1260
- pod .GetName (): {Err : fmt . Errorf ("" )},
1259
+ pod .GetName (): {Err : errors . New ("" )},
1261
1260
// Fail a single SyncFail hook
1262
- failedSyncFailHook .GetName (): {Err : fmt . Errorf ("" )},
1261
+ failedSyncFailHook .GetName (): {Err : errors . New ("" )},
1263
1262
},
1264
1263
}
1265
1264
syncCtx .resourceOps = & mockResourceOps
0 commit comments