Skip to content

Commit

Permalink
test: add simple test case
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Jul 17, 2024
1 parent ddb96f6 commit 8582afc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: garden.io/v1
kind: Project
name: disabled-action-with-duplicate-name
defaultEnvironment: local
environments:
- name: local
- name: remote
providers:
- name: exec
environments: [ local, remote ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: Run
name: run-script
type: exec
disabled: "${environment.name != 'local'}"
spec:
command: ["sh", "-c", "echo 'Hello from local'"]

---

kind: Run
name: run-script
type: exec
disabled: "${environment.name != 'remote'}"
spec:
command: ["sh", "-c", "echo 'Hello from remote'"]
11 changes: 11 additions & 0 deletions core/test/unit/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3041,6 +3041,17 @@ describe("Garden", () => {
expect(omit(test.internal, "yamlDoc")).to.eql(internal)
})

it("should resolve disabled flag in actions and allow two actions with same key if one is disabled", async () => {
const garden = await makeTestGarden(getDataDir("test-projects", "disabled-action-with-duplicate-name"))
const graph = await garden.getConfigGraph({ log: garden.log, emit: false })

// There are 2 'run-script' actions defined in the project, one per environment.
// This test uses 'local' environment, so the action for 'remote' environment should be disabled and skipped.
const runScript = graph.getRun("run-script")
expect(runScript.isDisabled()).to.be.false
expect(runScript.getConfig().spec.command).to.eql(["sh", "-c", "echo 'Hello from local'"])
})

it("should resolve actions from templated config templates", async () => {
const garden = await makeTestGarden(getDataDir("test-projects", "config-templates-with-templating"))
await garden.scanAndAddConfigs()
Expand Down

0 comments on commit 8582afc

Please sign in to comment.