Skip to content

Commit 8e5d7cb

Browse files
authored
Merge pull request kubernetes#127250 from bart0sh/PR157-Kubelet-DRA-fix-testify-errors
Kubelet: DRA: fix testify errors
2 parents 1fdb8e3 + e70a2ad commit 8e5d7cb

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

pkg/kubelet/cm/dra/claiminfo_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"testing"
2424

2525
"github.com/stretchr/testify/assert"
26+
"github.com/stretchr/testify/require"
2627

2728
resourceapi "k8s.io/api/resource/v1alpha3"
2829
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -307,7 +308,7 @@ func TestClaimInfoHasPodReference(t *testing.T) {
307308
},
308309
} {
309310
t.Run(test.description, func(t *testing.T) {
310-
assert.Equal(t, test.claimInfo.hasPodReference(podUID), test.expectedResult)
311+
assert.Equal(t, test.expectedResult, test.claimInfo.hasPodReference(podUID))
311312
})
312313
}
313314
}
@@ -401,7 +402,7 @@ func TestClaimInfoIsPrepared(t *testing.T) {
401402
},
402403
} {
403404
t.Run(test.description, func(t *testing.T) {
404-
assert.Equal(t, test.claimInfo.isPrepared(), test.expectedResult)
405+
assert.Equal(t, test.expectedResult, test.claimInfo.isPrepared())
405406
})
406407
}
407408
}
@@ -440,7 +441,7 @@ func TestNewClaimInfoCache(t *testing.T) {
440441
assert.Error(t, err)
441442
return
442443
}
443-
assert.NoError(t, err)
444+
require.NoError(t, err)
444445
assert.NotNil(t, result)
445446
})
446447
}
@@ -494,7 +495,7 @@ func TestClaimInfoCacheWithLock(t *testing.T) {
494495
} {
495496
t.Run(test.description, func(t *testing.T) {
496497
cache, err := newClaimInfoCache(t.TempDir(), "test-checkpoint")
497-
assert.NoError(t, err)
498+
require.NoError(t, err)
498499
assert.NotNil(t, cache)
499500
err = cache.withLock(test.funcGen(cache))
500501
if test.wantErr {
@@ -554,7 +555,7 @@ func TestClaimInfoCacheWithRLock(t *testing.T) {
554555
} {
555556
t.Run(test.description, func(t *testing.T) {
556557
cache, err := newClaimInfoCache(t.TempDir(), "test-checkpoint")
557-
assert.NoError(t, err)
558+
require.NoError(t, err)
558559
assert.NotNil(t, cache)
559560
err = cache.withRLock(test.funcGen(cache))
560561
if test.wantErr {
@@ -583,7 +584,7 @@ func TestClaimInfoCacheAdd(t *testing.T) {
583584
} {
584585
t.Run(test.description, func(t *testing.T) {
585586
cache, err := newClaimInfoCache(t.TempDir(), "test-checkpoint")
586-
assert.NoError(t, err)
587+
require.NoError(t, err)
587588
assert.NotNil(t, cache)
588589
cache.add(test.claimInfo)
589590
assert.True(t, cache.contains(test.claimInfo.ClaimName, test.claimInfo.Namespace))
@@ -754,13 +755,13 @@ func TestSyncToCheckpoint(t *testing.T) {
754755
} {
755756
t.Run(test.description, func(t *testing.T) {
756757
cache, err := newClaimInfoCache(test.stateDir, test.checkpointName)
757-
assert.NoError(t, err)
758+
require.NoError(t, err)
758759
err = cache.syncToCheckpoint()
759760
if test.wantErr {
760761
assert.Error(t, err)
761762
return
762763
}
763-
assert.NoError(t, err)
764+
require.NoError(t, err)
764765
})
765766
}
766767
}

pkg/kubelet/cm/dra/manager_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func TestNewManagerImpl(t *testing.T) {
196196
return
197197
}
198198

199-
assert.NoError(t, err)
199+
require.NoError(t, err)
200200
assert.NotNil(t, manager.cache)
201201
assert.NotNil(t, manager.kubeClient)
202202
})
@@ -355,7 +355,7 @@ func TestGetResources(t *testing.T) {
355355
} {
356356
t.Run(test.description, func(t *testing.T) {
357357
manager, err := NewManagerImpl(kubeClient, t.TempDir(), "worker")
358-
assert.NoError(t, err)
358+
require.NoError(t, err)
359359

360360
if test.claimInfo != nil {
361361
manager.cache.add(test.claimInfo)
@@ -593,7 +593,7 @@ func TestPrepareResources(t *testing.T) {
593593
return // PrepareResources returned an error so stopping the test case here
594594
}
595595

596-
assert.NoError(t, err)
596+
require.NoError(t, err)
597597

598598
if test.wantResourceSkipped {
599599
return // resource skipped so no need to continue
@@ -735,7 +735,7 @@ func TestUnprepareResources(t *testing.T) {
735735
return // PrepareResources returned an error so stopping the test case here
736736
}
737737

738-
assert.NoError(t, err)
738+
require.NoError(t, err)
739739

740740
if test.wantResourceSkipped {
741741
return // resource skipped so no need to continue
@@ -859,7 +859,7 @@ func TestGetContainerClaimInfos(t *testing.T) {
859859
return
860860
}
861861

862-
assert.NoError(t, err)
862+
require.NoError(t, err)
863863
assert.Len(t, claimInfos, 1)
864864
assert.Equal(t, test.expectedClaimName, claimInfos[0].ClaimInfoState.ClaimName)
865865
})

pkg/kubelet/cm/dra/plugin/plugin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func TestNewDRAPluginClient(t *testing.T) {
223223
assert.Error(t, err)
224224
} else {
225225
assert.NotNil(t, client)
226-
assert.Nil(t, err)
226+
assert.NoError(t, err)
227227
}
228228
})
229229
}

0 commit comments

Comments
 (0)