github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/app_deletion_test.go (about) 1 package e2e 2 3 import ( 4 "testing" 5 6 . "github.com/argoproj/gitops-engine/pkg/sync/common" 7 "github.com/stretchr/testify/assert" 8 9 . "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" 10 . "github.com/argoproj/argo-cd/v2/test/e2e/fixture" 11 . "github.com/argoproj/argo-cd/v2/test/e2e/fixture/app" 12 ) 13 14 // when a app gets stuck in sync, and we try to delete it, it won't delete, instead we must then terminate it 15 // and deletion will then just happen 16 func TestDeletingAppStuckInSync(t *testing.T) { 17 Given(t). 18 And(func() { 19 SetResourceOverrides(map[string]ResourceOverride{ 20 "ConfigMap": { 21 HealthLua: `return { status = obj.annotations and obj.annotations['health'] or 'Progressing' }`, 22 }, 23 }) 24 }). 25 Async(true). 26 Path("hook-custom-health"). 27 When(). 28 CreateApp(). 29 Sync(). 30 Then(). 31 // stuck in running state 32 Expect(OperationPhaseIs(OperationRunning)). 33 Expect(SyncStatusIs(SyncStatusCodeOutOfSync)). 34 When(). 35 Delete(true). 36 Then(). 37 // delete is ignored, still stuck in running state 38 Expect(OperationPhaseIs(OperationRunning)). 39 When(). 40 TerminateOp(). 41 Then(). 42 // delete is successful 43 Expect(DoesNotExist()) 44 } 45 46 func TestDeletingAppByLabel(t *testing.T) { 47 Given(t). 48 Path(guestbookPath). 49 When(). 50 CreateApp("--label=foo=bar"). 51 Sync(). 52 Then(). 53 Expect(SyncStatusIs(SyncStatusCode(SyncStatusCodeSynced))). 54 When(). 55 IgnoreErrors(). 56 DeleteBySelector("foo=baz"). 57 Then(). 58 // delete is unsuccessful since no selector match 59 AndCLIOutput( 60 func(output string, err error) { 61 assert.Contains(t, err.Error(), "no apps match selector foo=baz") 62 }, 63 ). 64 When(). 65 DeleteBySelector("foo=bar"). 66 Then(). 67 // delete is successful 68 Expect(DoesNotExist()) 69 }