Skip to content

Commit

Permalink
feat: verify apply out of sync flag
Browse files Browse the repository at this point in the history
Signed-off-by: pashakostohrys <[email protected]>
  • Loading branch information
pasha-codefresh committed Aug 11, 2023
1 parent 9681bee commit eb1c365
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/fixture/app/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ func (a *Actions) Sync(args ...string) *Actions {
args = append(args, "--force")
}

if a.context.applyOutOfSyncOnly {
args = append(args, "--apply-out-of-sync-only")
}

if a.context.replace {
args = append(args, "--replace")
}
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/fixture/app/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Context struct {
project string
revision string
force bool
applyOutOfSyncOnly bool
directoryRecurse bool
replace bool
helmPassCredentials bool
Expand Down Expand Up @@ -341,6 +342,11 @@ func (c *Context) Force() *Context {
return c
}

func (c *Context) ApplyOutOfSyncOnly() *Context {
c.applyOutOfSyncOnly = true
return c
}

func (c *Context) HelmPassCredentials() *Context {
c.helmPassCredentials = true
return c
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/sync_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ func TestSyncWithStatusIgnored(t *testing.T) {
Expect(SyncStatusIs(SyncStatusCodeSynced))
}

func TestSyncWithApplyOutOfSyncOnly(t *testing.T) {
Given(t).
Path(guestbookPath).
ApplyOutOfSyncOnly().
When().
CreateFromFile(func(app *Application) {
}).
Then().
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
// app should remain synced when app has skipped annotation even if git change detected
When().
PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "replace", "path": "/spec/replicas", "value": 1 }]`).
Sync().
Then().
Expect(ResourceResultIs(ResourceResult{Group: "apps", Version: "v1", Kind: "Deployment", Namespace: "guestbook", Name: "guestbook-ui", Message: "deployment.apps/guestbook-ui created", SyncPhase: SyncPhaseSync, HookPhase: OperationRunning}))
}

func TestSyncWithSkipHook(t *testing.T) {
fixture.SkipOnEnv(t, "OPENSHIFT")
Given(t).
Expand Down

0 comments on commit eb1c365

Please sign in to comment.