Merge pull request #3132 from Fish-pro/chore/unittest

Modify unit tests that never fail
This commit is contained in:
karmada-bot 2023-02-10 12:36:52 +08:00 committed by GitHub
commit 78c3f35cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 8 deletions

View File

@ -276,23 +276,30 @@ func TestStrategy_AllowUnconditionalUpdate(t *testing.T) {
func TestStrategy_Canonicalize(t *testing.T) {
clusterStrategy := NewStrategy(clusterscheme.Scheme)
clusterBefore := getValidCluster("cluster")
clusterAfter := getValidCluster("cluster")
clusterAfter.Spec.Taints = []corev1.Taint{
cluster := getValidCluster("cluster")
cluster.Spec.Taints = []corev1.Taint{
{
Key: "foo",
Value: "abc",
Value: "bar",
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "bar",
Key: "foo1",
Value: "bar1",
Effect: corev1.TaintEffectNoExecute,
},
}
clusterStrategy.Canonicalize(clusterBefore)
if !reflect.DeepEqual(clusterAfter, clusterAfter) {
t.Errorf("Object mismatch! Excepted: \n%#v \ngot: \n%#v", clusterAfter, clusterAfter)
clusterStrategy.Canonicalize(cluster)
success := true
for _, taint := range cluster.Spec.Taints {
if taint.Effect == corev1.TaintEffectNoExecute && taint.TimeAdded == nil {
success = false
break
}
}
if !success {
t.Errorf("cluster canonicalize error, got: \n%#v", cluster)
}
}