Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude committed Jan 16, 2024
1 parent 923c827 commit 0e6eb95
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions pkg/workflows/management/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,90 @@ func TestCreatePostWorkloadInitFailure(t *testing.T) {
}
}

func TestCreateInstallComponentsFailure(t *testing.T) {
c := newCreateTest(t)
c.expectSetup()
c.expectCreateBootstrap()
c.expectPreflightValidationsToPass()
c.expectCAPIInstall()

gomock.InOrder(
c.clusterManager.EXPECT().InstallCustomComponents(
c.ctx, c.clusterSpec, c.bootstrapCluster, c.provider),

c.eksdInstaller.EXPECT().InstallEksdCRDs(c.ctx, c.clusterSpec, c.bootstrapCluster).Return(errors.New("test")),
)

c.clusterManager.EXPECT().SaveLogsManagementCluster(c.ctx, c.clusterSpec, c.bootstrapCluster)
c.clusterManager.EXPECT().SaveLogsWorkloadCluster(c.ctx, c.provider, c.clusterSpec, nil)

c.writer.EXPECT().Write(fmt.Sprintf("%s-checkpoint.yaml", c.clusterSpec.Cluster.Name), gomock.Any())

err := c.run()
if err == nil {
t.Fatalf("Create.Run() expected to return an error %v", err)
}
}

func TestCreateEKSAReleaseBundleFailure(t *testing.T) {
c := newCreateTest(t)
c.expectSetup()
c.expectCreateBootstrap()
c.expectPreflightValidationsToPass()
c.expectCAPIInstall()

gomock.InOrder(
c.clusterManager.EXPECT().InstallCustomComponents(
c.ctx, c.clusterSpec, c.bootstrapCluster, c.provider),

c.eksdInstaller.EXPECT().InstallEksdCRDs(c.ctx, c.clusterSpec, c.bootstrapCluster),

c.clusterManager.EXPECT().CreateEKSAReleaseBundle(
c.ctx, c.bootstrapCluster, c.clusterSpec).Return(errors.New("test")),
)

c.clusterManager.EXPECT().SaveLogsManagementCluster(c.ctx, c.clusterSpec, c.bootstrapCluster)
c.clusterManager.EXPECT().SaveLogsWorkloadCluster(c.ctx, c.provider, c.clusterSpec, nil)

c.writer.EXPECT().Write(fmt.Sprintf("%s-checkpoint.yaml", c.clusterSpec.Cluster.Name), gomock.Any())

err := c.run()
if err == nil {
t.Fatalf("Create.Run() expected to return an error %v", err)
}
}

func TestCreateInstallEksdManifestFailure(t *testing.T) {
c := newCreateTest(t)
c.expectSetup()
c.expectCreateBootstrap()
c.expectPreflightValidationsToPass()
c.expectCAPIInstall()

gomock.InOrder(
c.clusterManager.EXPECT().InstallCustomComponents(
c.ctx, c.clusterSpec, c.bootstrapCluster, c.provider),

c.eksdInstaller.EXPECT().InstallEksdCRDs(c.ctx, c.clusterSpec, c.bootstrapCluster),

c.clusterManager.EXPECT().CreateEKSAReleaseBundle(
c.ctx, c.bootstrapCluster, c.clusterSpec),

c.eksdInstaller.EXPECT().InstallEksdManifest(
c.ctx, c.clusterSpec, c.bootstrapCluster).Return(errors.New("test")),
)

c.clusterManager.EXPECT().SaveLogsManagementCluster(c.ctx, c.clusterSpec, c.bootstrapCluster)
c.clusterManager.EXPECT().SaveLogsWorkloadCluster(c.ctx, c.provider, c.clusterSpec, nil)

c.writer.EXPECT().Write(fmt.Sprintf("%s-checkpoint.yaml", c.clusterSpec.Cluster.Name), gomock.Any())

err := c.run()
if err == nil {
t.Fatalf("Create.Run() expected to return an error %v", err)
}
}

func TestCreateMoveCAPIFailure(t *testing.T) {
c := newCreateTest(t)
c.expectSetup()
Expand Down

0 comments on commit 0e6eb95

Please sign in to comment.