Перейти к файлу
dependabot[bot] bd0417756d
Bump github.com/hashicorp/go-getter/v2 from 2.2.0 to 2.2.1 (#26)
Bumps [github.com/hashicorp/go-getter/v2](https://github.com/hashicorp/go-getter) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/go-getter/compare/v2.2.0...v2.2.1)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-20 15:58:19 +08:00
.devcontainer add devcontainer config 2022-12-28 10:34:43 +08:00
.github add dependabot config 2022-12-27 13:15:35 +08:00
bin/breaking_detect change main arg, add targetRef arg so we can use ref other than latest default branch in case the pr's target is not default branch. 2022-10-16 16:16:20 +08:00
example refactor code, add stream logger serialize output to stdout test 2023-02-01 19:35:12 +08:00
.gitignore refactor code, ignore TestRecord.md.tmp 2023-02-03 07:16:57 +08:00
CODE_OF_CONDUCT.md new files 2022-09-06 14:06:53 +08:00
LICENSE new files 2022-09-06 14:06:53 +08:00
README.md fix badge urls 2023-02-02 22:32:34 +08:00
SECURITY.md new files 2022-09-06 14:06:53 +08:00
breakingchange.go ignore .idea folder, resort imports 2023-01-19 15:22:18 +08:00
breakingchange_test.go Add e2e test. 2022-10-16 09:29:35 +08:00
e2etest.go remove init lock since we don't use plugin cache in test container any more 2023-03-16 16:34:47 +08:00
e2etest_test.go fallback from parallel when panic 2023-03-08 09:41:23 +08:00
go.mod Bump github.com/hashicorp/go-getter/v2 from 2.2.0 to 2.2.1 (#26) 2023-03-20 15:58:19 +08:00
go.sum Bump github.com/hashicorp/go-getter/v2 from 2.2.0 to 2.2.1 (#26) 2023-03-20 15:58:19 +08:00
module.go remove unused field 2022-10-31 16:53:35 +08:00
retryable_errors.go change ReadRetryableErrors argument's type from File to []byte 2022-11-22 18:46:00 +08:00
retryable_errors_sample.hcl.json add ReadRetryableErros method so acceptance tests can assign some errors to retry 2022-11-16 14:55:36 +08:00
retryable_errors_test.go ignore .idea folder, resort imports 2023-01-19 15:22:18 +08:00
stream_logger.go adjust logging sample output content 2023-02-02 11:54:12 +08:00
stream_logger_test.go remove logger name because the test logger output contains test name; add global lock for terraform init since we're running tests in parallel 2023-02-02 11:51:42 +08:00
unittest.go add unit test method, no synchronized logger or test snapshot in unit test 2023-02-21 13:40:38 +08:00
unittest_test.go add unit test method, no synchronized logger or test snapshot in unit test 2023-02-21 13:40:38 +08:00
upgradetest.go remove init lock since we don't use plugin cache in test container any more 2023-03-16 16:34:47 +08:00
upgradetest_test.go ignore .idea folder, resort imports 2023-01-19 15:22:18 +08:00
version_helper.go adjust file lock range 2023-02-17 14:33:14 +08:00
version_helper_test.go refactor code, ignore TestRecord.md.tmp 2023-02-03 07:16:57 +08:00

README.md

Azure Verified Terraform Module Test Helper

test lint

This repo contains two helper functions that were used to test Azure Verified Terraform Module.

For End-End test:

func TestExamplesStartup(t *testing.T) {
	vars := map[string]interface{}{
		"client_id":     "",
		"client_secret": "",
	}
	managedIdentityId := os.Getenv("MSI_ID")
	if managedIdentityId != "" {
		vars["managed_identity_principal_id"] = managedIdentityId
	}
	test_helper.RunE2ETest(t, "../../", "examples/startup", terraform.Options{
		Upgrade: true,
		Vars:    vars,
	}, func(t *testing.T, output test_helper.TerraformOutput) {
		aksId, ok := output["test_aks_id"].(string)
		assert.True(t, ok)
		assert.Regexp(t, regexp.MustCompile("/subscriptions/.+/resourceGroups/.+/providers/Microsoft.ContainerService/managedClusters/.+"), aksId)
	})
}

The RunE2ETest function accept module's root path, sub-folder to example code that our test want to apply, a terraform.Options argument, and an assertion callback.

In E2E test we apply the example code,then we execute terraform output and pass the json format output to this assertion callback, you can assert whether the output meets your spec there.

For Version-Upgrade Test:

func TestExampleUpgrade_startup(t *testing.T) {
	currentRoot, err := test_helper.GetCurrentModuleRootPath()
	if err != nil {
		t.FailNow()
	}
	currentMajorVersion, err := test_helper.GetCurrentMajorVersionFromEnv()
	if err != nil {
		t.FailNow()
	}
	vars := map[string]interface{}{
		"client_id":     "",
		"client_secret": "",
	}
	managedIdentityId := os.Getenv("MSI_ID")
	if managedIdentityId != "" {
		vars["managed_identity_principal_id"] = managedIdentityId
	}
	test_helper.ModuleUpgradeTest(t, "Azure", "terraform-azurerm-aks", "examples/startup", currentRoot, terraform.Options{
		Upgrade: true,
		Vars:    vars,
	}, currentMajorVersion)
}

The ModuleUpgradeTest function accept your Github repo's owner name (could be username or org name), repo name, sub-folder to example code, and module's current major version (eg: v3.0.0 major version is 3).

The ModuleUpgradeTest function will clone and checkout the latest released tag version within the major version you've passed, apply the code in a temp directory, then modify the module's source to the current path, then execute terraform plan to see if there would be any drift in the plan.