Skip to content

Commit

Permalink
chore: update tests to use blueprint test framework (#70)
Browse files Browse the repository at this point in the history
* chore: update tests to use blueprint test framework

* keep sa
  • Loading branch information
bharathkkb authored Mar 29, 2022
1 parent e94ccfb commit 59b6163
Show file tree
Hide file tree
Showing 19 changed files with 795 additions and 153 deletions.
42 changes: 0 additions & 42 deletions .kitchen.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.0
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.4
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
10 changes: 5 additions & 5 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ steps:
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT'
- id: create
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 && kitchen_do create']
args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose']
- id: converge
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 && kitchen_do converge']
args: ['/bin/bash', '-c', 'cft test run all --stage apply --verbose']
- id: verify
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 && kitchen_do verify']
args: ['/bin/bash', '-c', 'cft test run all --stage verify --verbose']
- 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 && kitchen_do destroy']
args: ['/bin/bash', '-c', 'cft test run all --stage teardown --verbose']
tags:
- 'ci'
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.4'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.4'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,15 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: pubsub_scheduled
depends:
- name: inspec-gcp
git: https://github.com/inspec/inspec-gcp.git
tag: v0.10.0
attributes:
- name: project_id
required: true
type: string
- name: name
required: true
type: string
apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintTest
metadata:
name: logs-slack-alerts
spec:
skip: true
1 change: 0 additions & 1 deletion examples/pubsub_scheduled/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ More information is in the [root readme](../../README.md#app-engine).
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| project\_id | The project ID to host the network in | `string` | n/a | yes |
| region | The region the project is in (App Engine specific) | `string` | `"us-central1"` | no |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion examples/pubsub_scheduled/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ module "pubsub_scheduled_example" {
function_entry_point = "doSomething"
function_source_directory = "${path.module}/function_source"
function_name = "testfunction-${random_pet.main.id}"
region = var.region
region = "us-central1"
topic_name = "pubsub_example_topic_${random_pet.main.id}"
}
5 changes: 0 additions & 5 deletions examples/pubsub_scheduled/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ variable "project_id" {
description = "The project ID to host the network in"
}

variable "region" {
type = string
description = "The region the project is in (App Engine specific)"
default = "us-central1"
}
1 change: 0 additions & 1 deletion examples/pubsub_scheduled_multiple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ More information is in the [root readme](../../README.md#app-engine).
|------|-------------|
| name | The name of the job created |
| project\_id | The project ID |
| scheduler\_job | An existing Cloud Scheduler job instance |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6 changes: 0 additions & 6 deletions examples/pubsub_scheduled_multiple/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,3 @@ output "project_id" {
value = var.project_id
description = "The project ID"
}

output "scheduler_job" {
value = module.pubsub_scheduled_1.scheduler_job
description = "An existing Cloud Scheduler job instance"
}

21 changes: 0 additions & 21 deletions test/fixtures/pubsub_scheduled/main.tf

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/pubsub_scheduled/outputs.tf

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/pubsub_scheduled/variables.tf

This file was deleted.

25 changes: 25 additions & 0 deletions test/integration/discover_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package test

import (
"testing"

"github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test/pkg/tft"
)

func TestAll(t *testing.T) {
tft.AutoDiscoverAndTest(t)
}
8 changes: 8 additions & 0 deletions test/integration/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/terraform-google-modules/terraform-google-scheduled-function/test/integration

go 1.16

require (
github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test v0.0.0-20220317050137-1c8897fbd42c
github.com/stretchr/testify v1.7.0
)
Loading

0 comments on commit 59b6163

Please sign in to comment.