github.com/argoproj/argo-cd@v1.8.7/test/e2e/delarative_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/pkg/apis/application/v1alpha1"
    10  	. "github.com/argoproj/argo-cd/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  		When().
    59  		Delete(false).
    60  		Then().
    61  		Expect(Success("")).
    62  		Expect(DoesNotExist())
    63  }
    64  
    65  func TestDeclarativeInvalidRepoURL(t *testing.T) {
    66  	Given(t).
    67  		Path("whatever").
    68  		When().
    69  		DeclarativeWithCustomRepo("declarative-apps/app.yaml", "http://github.com").
    70  		Then().
    71  		Expect(Success("")).
    72  		Expect(HealthIs(health.HealthStatusHealthy)).
    73  		Expect(SyncStatusIs(SyncStatusCodeUnknown)).
    74  		Expect(Condition(ApplicationConditionComparisonError, "repository not found")).
    75  		When().
    76  		Delete(false).
    77  		Then().
    78  		Expect(Success("")).
    79  		Expect(DoesNotExist())
    80  }