Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcurtis committed Aug 4, 2024
1 parent 637f8c6 commit 986b4d0
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ No requirements.

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | 5.39.1 |
| <a name="provider_google"></a> [google](#provider\_google) | 5.38.0 |

### Modules

Expand Down
2 changes: 1 addition & 1 deletion regional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ No requirements.

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | 5.39.1 |
| <a name="provider_google"></a> [google](#provider\_google) | 5.38.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.14.0 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.31.0 |

Expand Down
22 changes: 14 additions & 8 deletions tests/default.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ run "primary_regional" {
}
}

run "remote" {
command = apply

module {
source = "./tests/fixtures/remote"
}
variables {
gke_fleet_host_project_id = "mock-fleet-host-project"
}
}

run "remote_regional" {
command = apply

Expand All @@ -60,13 +71,8 @@ run "remote_regional" {
}

variables {
istio_external_istiod = true
istio_gateway_dns = {
"mock-region-b.mock-environment.mock-subdomain.mock-domain" = {
managed_zone = "mock-environment-mock-subdomain-mock-domain"
project = "mock-dns-project"
}
}
region = "mock-region-b"
gke_fleet_host_project_id = "mock-fleet-host-project"
istio_external_istiod = true
region = "mock-region-b"
}
}
12 changes: 12 additions & 0 deletions tests/fixtures/remote/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Local Values
# https://www.terraform.io/docs/language/values/locals.html

locals {
labels = {
cost-center = "mock-x001"
env = var.environment
repository = "mock-repository"
platform = "mock-platform"
team = "mock-team"
}
}
17 changes: 17 additions & 0 deletions tests/fixtures/remote/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Required Providers
# https://developer.hashicorp.com/terraform/language/providers/requirements

terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
}

module "test" {
source = "../../../"

labels = local.labels
project = var.project
}
10 changes: 10 additions & 0 deletions tests/fixtures/remote/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Output Values
# https://www.terraform.io/language/values/outputs

output "istio_gateway_mci_global_address" {
value = module.test.istio_gateway_mci_global_address
}

output "istio_gateway_mci_ssl_certificate_name" {
value = module.test.istio_gateway_mci_ssl_certificate_name
}
3 changes: 1 addition & 2 deletions tests/fixtures/remote/regional/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ module "test" {
enable_istio_gateway = true
istio_external_istiod = var.istio_external_istiod
istio_control_plane_clusters = var.istio_control_plane_clusters
istio_gateway_dns = var.istio_gateway_dns
istio_remote_injection_path = var.istio_remote_injection_path
istio_remote_injection_url = var.istio_remote_injection_url
labels = local.labels
project = var.project
region = var.region
}
}
11 changes: 4 additions & 7 deletions tests/fixtures/remote/regional/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ variable "environment" {
type = string
}

variable "gke_fleet_host_project_id" {
type = string
}

variable "istio_control_plane_clusters" {
type = string
default = null
}

variable "istio_gateway_dns" {
type = map(object({
managed_zone = string
project = string
}))
}

variable "istio_external_istiod" {
type = bool
default = false
Expand Down
14 changes: 14 additions & 0 deletions tests/fixtures/remote/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Input Variables
# https://www.terraform.io/language/values/variables

variable "environment" {
type = string
}

variable "gke_fleet_host_project_id" {
type = string
}

variable "project" {
type = string
}

0 comments on commit 986b4d0

Please sign in to comment.