Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Review Fixes for Implement integration testing for Terraform Validator
Browse files Browse the repository at this point in the history
Added Cloud Build config to build folder and needed resources provisioning to tests folder. It's not very clean option because project already had test folder for go testing.

Related PR GoogleCloudPlatform/cloud-foundation-toolkit#376
  • Loading branch information
kopachevsky committed Oct 25, 2019
1 parent 4289352 commit d6248aa
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 214 deletions.
20 changes: 3 additions & 17 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,15 @@ steps:
name: 'gcr.io/cloud-builders/go'
entrypoint: /usr/bin/make
args: [build]
- id: prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment']
env:
- 'TF_VAR_org_id=$_ORG_ID'
- 'TF_VAR_folder_id=$_FOLDER_ID'
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT'
- id: print_source
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cat test/source.sh']
- id: test-integration
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source test/source.sh && make test-integration']
- id: destroy
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && cleanup_environment']
args: ['/bin/bash', '-c', 'make test-integration']
env:
- 'TF_VAR_org_id=$_ORG_ID'
- 'TF_VAR_folder_id=$_FOLDER_ID'
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT'
- 'TEST_PROJECT=$_TEST_PROJECT'
tags:
- 'ci'
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.1.0'

2 changes: 0 additions & 2 deletions test/setup/.gitignore

This file was deleted.

39 changes: 0 additions & 39 deletions test/setup/iam.tf

This file was deleted.

35 changes: 0 additions & 35 deletions test/setup/main.tf

This file was deleted.

27 changes: 0 additions & 27 deletions test/setup/make_source.sh

This file was deleted.

28 changes: 0 additions & 28 deletions test/setup/outputs.tf

This file was deleted.

31 changes: 0 additions & 31 deletions test/setup/variables.tf

This file was deleted.

27 changes: 0 additions & 27 deletions test/setup/versions.tf

This file was deleted.

16 changes: 8 additions & 8 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ func configure(t *testing.T) config {
}

cfg.credentials, ok = os.LookupEnv("TEST_CREDENTIALS")
if !ok {
t.Fatal("missing required env var TEST_CREDENTIALS")
}
// Make credentials path relative to repo root rather than
// test/ dir if it is a relative path.
if !filepath.IsAbs(cfg.credentials) {
cfg.credentials = filepath.Join("..", cfg.credentials)
if ok {
// Make credentials path relative to repo root rather than
// test/ dir if it is a relative path.
if !filepath.IsAbs(cfg.credentials) {
cfg.credentials = filepath.Join("..", cfg.credentials)
}
} else {
t.Log("missing env var TEST_CREDENTIALS, will try to use Application Default Credentials")
}

return cfg
}

Expand Down

0 comments on commit d6248aa

Please sign in to comment.