Files
deploy/test/e2e/hydrator_test.go
8334da36f2 Bump major version to 3 (#21410)
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: crenshaw-dev <[email protected]>
2025-01-10 16:14:00 -05:00

103 lines
2.4 KiB
Go

package e2e
import (
"testing"
. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
. "github.com/argoproj/gitops-engine/pkg/sync/common"
)
func TestSimpleHydrator(t *testing.T) {
Given(t).
DrySourcePath("guestbook").
DrySourceRevision("HEAD").
SyncSourcePath("guestbook").
SyncSourceBranch("env/test").
When().
CreateApp().
Refresh(RefreshTypeNormal).
Wait("--hydrated").
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced))
}
func TestHydrateTo(t *testing.T) {
Given(t).
DrySourcePath("guestbook").
DrySourceRevision("HEAD").
SyncSourcePath("guestbook").
SyncSourceBranch("env/test").
HydrateToBranch("env/test-next").
When().
CreateApp().
Refresh(RefreshTypeNormal).
Wait("--hydrated").
Then().
Given().
// Async so we don't fail immediately on the error
Async(true).
When().
Sync().
Wait("--operation").
Then().
// Fails because we hydrated to env/test-next but not to env/test.
Expect(OperationPhaseIs(OperationError)).
When().
// Will now hydrate to the sync source branch.
AppSet("--hydrate-to-branch", "").
Refresh(RefreshTypeNormal).
Wait("--hydrated").
Sync().
Wait("--operation").
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced))
}
func TestAddingApp(t *testing.T) {
// Make sure that if we add another app targeting the same sync branch, it hydrates correctly.
Given(t).
Name("test-adding-app-1").
DrySourcePath("guestbook").
DrySourceRevision("HEAD").
SyncSourcePath("guestbook-1").
SyncSourceBranch("env/test").
When().
CreateApp().
Refresh(RefreshTypeNormal).
Wait("--hydrated").
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Given().
Name("test-adding-app-2").
DrySourcePath("guestbook").
DrySourceRevision("HEAD").
SyncSourcePath("guestbook-2").
SyncSourceBranch("env/test").
When().
CreateApp().
Refresh(RefreshTypeNormal).
Wait("--hydrated").
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
// Clean up the apps manually since we used custom names.
When().
Delete(true).
Then().
Expect(DoesNotExist()).
Given().
Name("test-adding-app-1").
When().
Delete(true).
Then().
Expect(DoesNotExist())
}