github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/declarative_test.go (about)

     1  package e2e
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/argoproj/gitops-engine/pkg/health"
     7  	. "github.com/argoproj/gitops-engine/pkg/sync/common"
     8  
     9  	. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
    10  	. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
    11  )
    12  
    13  func TestDeclarativeHappyApp(t *testing.T) {
    14  	Given(t).
    15  		Path("guestbook").
    16  		When().
    17  		Declarative("declarative-apps/app.yaml").
    18  		Then().
    19  		Expect(Success("")).
    20  		Expect(HealthIs(health.HealthStatusMissing)).
    21  		Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
    22  		When().
    23  		Sync().
    24  		Then().
    25  		Expect(OperationPhaseIs(OperationSucceeded)).
    26  		Expect(HealthIs(health.HealthStatusHealthy)).
    27  		Expect(SyncStatusIs(SyncStatusCodeSynced))
    28  }
    29  
    30  func TestDeclarativeInvalidPath(t *testing.T) {
    31  	Given(t).
    32  		Path("garbage").
    33  		When().
    34  		Declarative("declarative-apps/app.yaml").
    35  		Then().
    36  		Expect(Success("")).
    37  		Expect(HealthIs(health.HealthStatusHealthy)).
    38  		Expect(SyncStatusIs(SyncStatusCodeUnknown)).
    39  		Expect(Condition(ApplicationConditionComparisonError, "garbage: app path does not exist")).
    40  		When().
    41  		Delete(false).
    42  		Then().
    43  		Expect(Success("")).
    44  		Expect(DoesNotExist())
    45  }
    46  
    47  func TestDeclarativeInvalidProject(t *testing.T) {
    48  	Given(t).
    49  		Path("guestbook").
    50  		Project("garbage").
    51  		When().
    52  		Declarative("declarative-apps/app.yaml").
    53  		Then().
    54  		Expect(Success("")).
    55  		Expect(HealthIs(health.HealthStatusUnknown)).
    56  		Expect(SyncStatusIs(SyncStatusCodeUnknown)).
    57  		Expect(Condition(ApplicationConditionInvalidSpecError, "Application referencing project garbage which does not exist"))
    58  
    59  	// TODO: you can`t delete application with invalid project due to enforcment that was recently added,
    60  	// in https://github.com/argoproj/argo-cd/security/advisories/GHSA-2gvw-w6fj-7m3c
    61  	// When().
    62  	// Delete(false).
    63  	// Then().
    64  	// Expect(Success("")).
    65  	// Expect(DoesNotExist())
    66  }
    67  
    68  func TestDeclarativeInvalidRepoURL(t *testing.T) {
    69  	Given(t).
    70  		Path("whatever").
    71  		When().
    72  		DeclarativeWithCustomRepo("declarative-apps/app.yaml", "https://github.com").
    73  		Then().
    74  		Expect(Success("")).
    75  		Expect(HealthIs(health.HealthStatusHealthy)).
    76  		Expect(SyncStatusIs(SyncStatusCodeUnknown)).
    77  		Expect(Condition(ApplicationConditionComparisonError, "repository not found")).
    78  		When().
    79  		Delete(false).
    80  		Then().
    81  		Expect(Success("")).
    82  		Expect(DoesNotExist())
    83  }