diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eb8d484..b03a986 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,37 +6,8 @@ To create a new module, clone this repository and run: ./new.sh MOUDLE_NAME ``` -Test a module by running an instance of Coder on your local machine: - -```shell -coder server --in-memory -``` - -This will create a new module in the modules directory with the given name and scaffolding. -Edit the files, adding your module's implementation, documentation and screenshots. - ## Testing a Module -Create a template and edit it to include your development module: - -> [!NOTE] -> The Docker starter template is recommended for quick-iteration! - -```hcl -module "MOUDLE_NAME" { - source = "/home/user/coder/modules/MOUDLE_NAME" -} -``` - -You can also test your module by specifying the source as a git repository: - -```hcl -module "MOUDLE_NAME" { - source = "git::https://github.com//.git//?ref=" -} -``` - -Build a workspace and your module will be consumed! 🥳 +A suite of test-helpers exists to run `terraform apply` on modules with variables, and test script output against containers. -Open a pull-request with your module, a member of the Coder team will -manually test it, and after-merge it will appear on the Registry. +Reference existing `*.test.ts` files for implementation. diff --git a/aws-region/main.test.ts b/aws-region/main.test.ts new file mode 100644 index 0000000..f943f94 --- /dev/null +++ b/aws-region/main.test.ts @@ -0,0 +1,25 @@ +import { describe, expect, it } from "bun:test"; +import { + executeScriptInContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "../test"; + +describe("aws-region", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, {}); + + it("default output", async () => { + const state = await runTerraformApply(import.meta.dir, {}); + expect(state.outputs.value.value).toBe("us-east-1"); + }); + + it("customized default", async () => { + const state = await runTerraformApply(import.meta.dir, { + default: "us-west-2", + }); + expect(state.outputs.value.value).toBe("us-west-2"); + }); +}); diff --git a/test.ts b/test.ts index cc43018..b4c384f 100644 --- a/test.ts +++ b/test.ts @@ -74,6 +74,12 @@ export const execContainer = async ( }; export interface TerraformState { + outputs: { + [key: string]: { + type: string; + value: any; + }; + } resources: [ { type: string;