test: ?????????

This commit is contained in:
Michael Smith
2025-01-27 20:28:14 +00:00
parent e28138adb7
commit df53f96951
3 changed files with 13 additions and 8 deletions

View File

@@ -16,9 +16,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up job
- name: Check out code
uses: actions/checkout@v4
- name: Set up Terraform (replace with Coder action if possible)
- name: Set up Terraform (REPLACE WITH CODER ACTION WHEN DONE)
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.9.8
@@ -29,9 +29,9 @@ jobs:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Verify that Terraform is installed
- name: Verify that Terraform is installed (REMOVE WHEN DONE)
run: which terraform
- name: Verify that Node.js is installed
- name: Verify that Node.js is installed (REMOVE WHEN DONE)
run: which node
- name: Run tests
run: bun test

View File

@@ -25,7 +25,7 @@ const removeOldContainers = async () => {
"-a",
"-q",
"--filter",
`label=modules-test`,
"label=modules-test",
]);
let containerIDsRaw = await readableStreamToText(proc.stdout);
let exitCode = await proc.exited;

11
test.ts
View File

@@ -194,13 +194,18 @@ export const testRequiredVariables = <TVars extends TerraformVariables>(
export const runTerraformApply = async <TVars extends TerraformVariables>(
dir: string,
vars: Readonly<TVars>,
env?: Record<string, string>,
customEnv?: Record<string, string>,
): Promise<TerraformState> => {
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`;
const combinedEnv = env === undefined ? {} : { ...env };
const combinedEnv: Record<string, string | undefined> = {
...process.env,
...(customEnv ?? {}),
};
for (const [key, value] of Object.entries(vars)) {
combinedEnv[`TF_VAR_${key}`] = String(value);
if (value !== null) {
combinedEnv[`TF_VAR_${key}`] = String(value);
}
}
const proc = spawn(