Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created January 11, 2022 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanwit/5d06109da710296a5cf4c90a23247bbc to your computer and use it in GitHub Desktop.
Save chanwit/5d06109da710296a5cf4c90a23247bbc to your computer and use it in GitHub Desktop.
SPEC: This spec describes the behaviour of a Terraform resource with no backend, and `auto` approve.
IT should be reconciled to have available outputs.
GIVEN: a GitRepository
BY: defining a new GitRepository resource.
BY: creating the GitRepository resource in the cluster.
IT should be created successfully.
GIVEN: the GitRepository's reconciled status.
BY: setting the GitRepository's status, with the downloadable BLOB's URL, and the correct checksum.
IT should be updated successfully.
GIVEN: a Terraform resource with auto approve, attached to the given GitRepository resource.
BY: creating a new TF resource and attaching to the repo via `sourceRef`.
IT should be created and attached successfully.
BY: checking that the TF resource existed inside the cluster.
IT should be reconciled and contain some status conditions.
BY: checking that the TF resource's status conditions has some elements.
IT should be planned.
BY: checking that the Plan's reason of the TF resource become `TerraformPlannedWithChanges`.
IT should generate the Secret containing the plan named with branch and commit id.
BY: checking that the Secret contains plan-master-b8e362c206e3d0cbb7ed22ced771a0056455a2fb in its labels.
IT should contain an Apply condition saying that the plan were apply successfully.
BY: checking that the reason of the Apply condition is TerraformAppliedSucceed, and the LastAppliedPlan is the plan.
IT should have an available output.
BY: checking that the Terraform resource's .status.availableOutputs contains hello_world as an output name.
IT should not produce a Secret because the controller runs locally, outside Kubernetes.
BY: checking there are no secret generated by default.
--- PASS: Test_000010_no_outputs_test (1.05s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment