[ut] improve ut coverage for node.go

Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
xin.li 2023-02-05 18:07:59 +08:00
parent 8f83031603
commit e8a6e50a84
1 changed files with 19 additions and 0 deletions

View File

@ -169,6 +169,7 @@ func TestCommandInitOption_AddNodeSelectorLabels(t *testing.T) {
name string
option CommandInitOption
status corev1.ConditionStatus
spec corev1.NodeSpec
wantErr bool
}{
{
@ -177,6 +178,7 @@ func TestCommandInitOption_AddNodeSelectorLabels(t *testing.T) {
KubeClientSet: fake.NewSimpleClientset(),
},
status: corev1.ConditionTrue,
spec: corev1.NodeSpec{},
wantErr: false,
},
{
@ -185,6 +187,22 @@ func TestCommandInitOption_AddNodeSelectorLabels(t *testing.T) {
KubeClientSet: fake.NewSimpleClientset(),
},
status: corev1.ConditionFalse,
spec: corev1.NodeSpec{},
wantErr: true,
},
{
name: "there is taint node",
option: CommandInitOption{
KubeClientSet: fake.NewSimpleClientset(),
},
status: corev1.ConditionTrue,
spec: corev1.NodeSpec{
Taints: []corev1.Taint{
{
Effect: corev1.TaintEffectNoSchedule,
},
},
},
wantErr: true,
},
}
@ -197,6 +215,7 @@ func TestCommandInitOption_AddNodeSelectorLabels(t *testing.T) {
{Type: corev1.NodeReady, Status: tt.status},
},
},
Spec: tt.spec,
}, metav1.CreateOptions{})
if err != nil {
t.Errorf("create node error: %v", err)