Add aws-region tests

pull/48/head
Kyle Carberry 2 years ago
parent 030404939f
commit ed5b5864a4

@ -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/<USERNAME>/<REPO>.git//<FOLDER>?ref=<BRANCH>"
}
```
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.

@ -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");
});
});

@ -74,6 +74,12 @@ export const execContainer = async (
};
export interface TerraformState {
outputs: {
[key: string]: {
type: string;
value: any;
};
}
resources: [
{
type: string;

Loading…
Cancel
Save