add unit test coverage for pkg/kubelet/util/queue

Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>
This commit is contained in:
zhoumingcheng 2022-06-23 17:57:17 +08:00
parent 02462739ca
commit ca8f3dff9a

View File

@ -20,8 +20,10 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/utils/clock"
testingclock "k8s.io/utils/clock/testing"
)
@ -63,3 +65,19 @@ func TestGetWork(t *testing.T) {
compareResults(t, expected, q.GetWork())
compareResults(t, []types.UID{}, q.GetWork())
}
func TestNewBasicWorkQueue(t *testing.T) {
tests := []struct {
clock clock.Clock
expectedWorkQueue WorkQueue
}{
{
clock: clock.RealClock{},
expectedWorkQueue: &basicWorkQueue{queue: make(map[types.UID]time.Time), clock: clock.RealClock{}},
},
}
for _, test := range tests {
workQueue := NewBasicWorkQueue(test.clock)
assert.Equal(t, test.expectedWorkQueue, workQueue)
}
}