Skip to content

Commit

Permalink
fix Cleanup function
Browse files Browse the repository at this point in the history
Signed-off-by: Kasem Alem <[email protected]>
  • Loading branch information
Kasem Alem committed Dec 11, 2024
1 parent b51de25 commit 65aef68
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/integration-service/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests

AfterAll(func() {
if !CurrentSpecReport().Failed() {
cleanup(*f, testNamespace, applicationName, componentName)

Expect(f.AsKubeAdmin.IntegrationController.DeleteSnapshot(snapshotPush, testNamespace)).To(Succeed())
cleanup(*f, testNamespace, applicationName, componentName, snapshotPush)
}

// Delete new branches created by PaC and a testing branch used as a component's base branch
Expand Down Expand Up @@ -253,7 +251,7 @@ var _ = framework.IntegrationServiceSuiteDescribe("Integration Service E2E tests

AfterAll(func() {
if !CurrentSpecReport().Failed() {
cleanup(*f, testNamespace, applicationName, componentName)
cleanup(*f, testNamespace, applicationName, componentName, snapshotPush)
}

// Delete new branches created by PaC and a testing branch used as a component's base branch
Expand Down Expand Up @@ -493,16 +491,17 @@ func createComponentWithCustomBranch(f framework.Framework, testNamespace, appli
return originalComponent
}

func cleanup(f framework.Framework, testNamespace, applicationName, componentName string) {
func cleanup(f framework.Framework, testNamespace, applicationName, componentName string, snapshot *appstudioApi.Snapshot) {
if !CurrentSpecReport().Failed() {
Expect(f.AsKubeAdmin.HasController.DeleteApplication(applicationName, testNamespace, false)).To(Succeed())
Expect(f.AsKubeAdmin.HasController.DeleteComponent(componentName, testNamespace, false)).To(Succeed())
Expect(f.AsKubeAdmin.IntegrationController.DeleteSnapshot(snapshot, testNamespace)).To(Succeed())
integrationTestScenarios, err := f.AsKubeAdmin.IntegrationController.GetIntegrationTestScenarios(applicationName, testNamespace)
Expect(err).ShouldNot(HaveOccurred())

for _, testScenario := range *integrationTestScenarios {
Expect(f.AsKubeAdmin.IntegrationController.DeleteIntegrationTestScenario(&testScenario, testNamespace)).To(Succeed())
}
Expect(f.AsKubeAdmin.HasController.DeleteComponent(componentName, testNamespace, false)).To(Succeed())
Expect(f.AsKubeAdmin.HasController.DeleteApplication(applicationName, testNamespace, false)).To(Succeed())
Expect(f.SandboxController.DeleteUserSignup(f.UserName)).To(BeTrue())
}
}

0 comments on commit 65aef68

Please sign in to comment.