Skip to content

Commit

Permalink
fix(tests): fix integ tests (TBS)
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Oct 10, 2024
1 parent b83f27f commit 4d339c8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
38 changes: 17 additions & 21 deletions core/src/graph/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { describeSchema, parseActionReference } from "../config/common.js"
import type { GroupConfig } from "../config/group.js"
import { ActionConfigContext } from "../config/template-contexts/actions.js"
import { validateWithPath } from "../config/validation.js"
import { ConfigurationError, PluginError, InternalError, ValidationError, GardenError } from "../exceptions.js"
import { ConfigurationError, PluginError, InternalError, GardenError } from "../exceptions.js"
import { overrideVariables, type Garden } from "../garden.js"
import type { Log } from "../logger/log-entry.js"
import type { ActionTypeDefinition } from "../plugin/action-types.js"
Expand Down Expand Up @@ -916,28 +916,24 @@ function dependenciesFromActionConfig({
}

const deps: ActionDependency[] = config.dependencies.map((d) => {
try {
const { kind, name } = parseActionReference(d)
const depKey = actionReferenceToString(d)
const depConfig = configsByKey[depKey]
if (!depConfig) {
throw new ConfigurationError({
message: `${description} references depdendency ${depKey}, but no such action could be found`,
})
}
return {
kind,
name,
type: depConfig.type,
explicit: true,
needsExecutedOutputs: false,
needsStaticOutputs: false,
}
} catch (error) {
throw new ValidationError({
message: `Invalid dependency specified: ${error}`,
const { kind, name } = parseActionReference(d)
const depKey = actionReferenceToString(d)
const depConfig = configsByKey[depKey]

if (!depConfig) {
throw new ConfigurationError({
message: `${description} references depdendency ${depKey}, but no such action could be found`,
})
}

return {
kind,
name,
type: depConfig.type,
explicit: true,
needsExecutedOutputs: false,
needsStaticOutputs: false,
}
})

function addDep(ref: ActionReference & { type: string }, attributes: ActionDependencyAttributes) {
Expand Down
8 changes: 8 additions & 0 deletions core/src/util/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ export class TestGarden extends Garden {
this.moduleConfigs = keyBy(moduleConfigs.map(moduleConfigWithDefaults), "name")
}

mergeModuleConfigs(moduleConfigs: PartialModuleConfig[]) {
this.state.configsScanned = true
this.moduleConfigs = {
...this.moduleConfigs,
...keyBy(moduleConfigs.map(moduleConfigWithDefaults), "name"),
}
}

setActionConfigs(actionConfigs: PartialActionConfig[]) {
this.actionConfigs = {
Build: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ tasks:
command: [sh, -c, "echo ok"]

---

kind: Run
name: echo-run-exec
type: kubernetes-exec
Expand All @@ -56,7 +55,6 @@ spec:
command: [echo, ok]

---

kind: Test
name: echo-test-exec
type: kubernetes-exec
Expand All @@ -66,4 +64,4 @@ spec:
resource:
kind: Deployment
name: busybox-deployment
command: [echo, ok]
command: [echo, ok]
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("kubernetes-type handlers", () => {
}

async function deployInNamespace({ nsName, deployName }: { nsName: string; deployName: string }) {
garden.setModuleConfigs([withNamespace(nsModuleConfig, nsName)])
garden.mergeModuleConfigs([withNamespace(nsModuleConfig, nsName)])
const graph = await garden.getConfigGraph({ log, emit: false })
const action = graph.getDeploy(deployName)
const resolvedAction = await garden.resolveAction<KubernetesDeployAction>({ action, log: garden.log, graph })
Expand Down

0 comments on commit 4d339c8

Please sign in to comment.