Skip to content

Commit 390fdf3

Browse files
authored
test: fix the crp ut flakiness (#132)
Signed-off-by: Zhiying Lin <[email protected]>
1 parent a25e422 commit 390fdf3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/controllers/clusterresourceplacement/controller_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,13 +2720,6 @@ func TestGetOrCreateClusterResourceSnapshot(t *testing.T) {
27202720
t.Fatalf("getOrCreateClusterResourceSnapshot() got RequeueAfter %v, want greater than zero value", res.RequeueAfter)
27212721
}
27222722
}
2723-
if diff := cmp.Diff(tc.wantResourceSnapshots[tc.wantLatestSnapshotIndex], *got, options...); diff != "" {
2724-
t.Errorf("getOrCreateClusterResourceSnapshot() mismatch (-want, +got):\n%s", diff)
2725-
}
2726-
clusterResourceSnapshotList := &fleetv1beta1.ClusterResourceSnapshotList{}
2727-
if err := fakeClient.List(ctx, clusterResourceSnapshotList); err != nil {
2728-
t.Fatalf("clusterResourceSnapshot List() got error %v, want no error", err)
2729-
}
27302723
annotationOption := cmp.Transformer("NormalizeAnnotations", func(m map[string]string) map[string]string {
27312724
normalized := map[string]string{}
27322725
for k, v := range m {
@@ -2743,6 +2736,13 @@ func TestGetOrCreateClusterResourceSnapshot(t *testing.T) {
27432736
return normalized
27442737
})
27452738
options = append(options, sortClusterResourceSnapshotOption, annotationOption)
2739+
if diff := cmp.Diff(tc.wantResourceSnapshots[tc.wantLatestSnapshotIndex], *got, options...); diff != "" {
2740+
t.Errorf("getOrCreateClusterResourceSnapshot() mismatch (-want, +got):\n%s", diff)
2741+
}
2742+
clusterResourceSnapshotList := &fleetv1beta1.ClusterResourceSnapshotList{}
2743+
if err := fakeClient.List(ctx, clusterResourceSnapshotList); err != nil {
2744+
t.Fatalf("clusterResourceSnapshot List() got error %v, want no error", err)
2745+
}
27462746
if diff := cmp.Diff(tc.wantResourceSnapshots, clusterResourceSnapshotList.Items, options...); diff != "" {
27472747
t.Errorf("clusterResourceSnapshot List() mismatch (-want, +got):\n%s", diff)
27482748
}

0 commit comments

Comments
 (0)