Skip to content

Commit

Permalink
remove getFakeDiscoveryTypes and directly use graph.getDiscoveryTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
archerwu9425 committed Nov 13, 2023
1 parent 949b0c6 commit e64aa00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
22 changes: 11 additions & 11 deletions cmd/clusterctl/client/cluster/mover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func Test_objectMover_backupTargetObject(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -826,7 +826,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
graph := getObjectGraph()

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -934,7 +934,7 @@ func Test_objectMover_toDirectory(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -1077,7 +1077,7 @@ func Test_objectMover_fromDirectory(t *testing.T) {
graph := getObjectGraph()

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// gets a fakeProxy to an empty cluster with all the required CRDs
toProxy := getFakeProxyWithCRDs()
Expand Down Expand Up @@ -1155,7 +1155,7 @@ func Test_getMoveSequence(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -1188,7 +1188,7 @@ func Test_objectMover_move_dryRun(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -1263,7 +1263,7 @@ func Test_objectMover_move(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -1375,7 +1375,7 @@ func Test_objectMover_move_with_Mutator(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -1660,7 +1660,7 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -1906,7 +1906,7 @@ func Test_objectMoverService_ensureNamespaces(t *testing.T) {
graph := getObjectGraphWithObjs(tt.fields.objs)

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// Trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down Expand Up @@ -2385,7 +2385,7 @@ func TestWaitReadyForMove(t *testing.T) {
}

// Get all the types to be considered for discovery
g.Expect(getFakeDiscoveryTypes(ctx, graph)).To(Succeed())
g.Expect(graph.getDiscoveryTypes(ctx)).To(Succeed())

// trigger discovery the content of the source cluster
g.Expect(graph.Discovery(ctx, "")).To(Succeed())
Expand Down
12 changes: 2 additions & 10 deletions cmd/clusterctl/client/cluster/objectgraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1774,14 +1774,6 @@ func getFakeProxyWithCRDs() *test.FakeProxy {
return proxy
}

func getFakeDiscoveryTypes(ctx context.Context, graph *objectGraph) error {
if err := graph.getDiscoveryTypes(ctx); err != nil {
return err
}

return nil
}

func TestObjectGraph_Discovery(t *testing.T) {
// NB. we are testing the graph is properly built starting from objects (TestGraphBuilder_addObj_WithFakeObjects) or from the same objects read from the cluster (this test).
for _, tt := range objectGraphsTests {
Expand All @@ -1794,7 +1786,7 @@ func TestObjectGraph_Discovery(t *testing.T) {
graph := getObjectGraphWithObjs(tt.args.objs)

// Get all the types to be considered for discovery
err := getFakeDiscoveryTypes(ctx, graph)
err := graph.getDiscoveryTypes(ctx)
g.Expect(err).ToNot(HaveOccurred())

// finally test discovery
Expand Down Expand Up @@ -1952,7 +1944,7 @@ func TestObjectGraph_DiscoveryByNamespace(t *testing.T) {
graph := getObjectGraphWithObjs(tt.args.objs)

// Get all the types to be considered for discovery
err := getFakeDiscoveryTypes(ctx, graph)
err := graph.getDiscoveryTypes(ctx)
g.Expect(err).ToNot(HaveOccurred())

// finally test discovery
Expand Down

0 comments on commit e64aa00

Please sign in to comment.