Skip to content

Commit

Permalink
add basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gareda committed Jan 21, 2024
1 parent 967ba8e commit ffdb0e1
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/environment/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
workspace_id = uuid()
}
4 changes: 4 additions & 0 deletions tests/environment/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "azurerm_resource_group" "rg" {
name = local.workspace_id
location = "West Europe"
}
11 changes: 11 additions & 0 deletions tests/environment/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "workspace_id" {
value = local.workspace_id
}

output "resource_group_name" {
value = azurerm_resource_group.rg.name
}

output "resource_group_location" {
value = azurerm_resource_group.rg.location
}
10 changes: 10 additions & 0 deletions tests/environment/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">=1.3.0"

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
}
}
46 changes: 46 additions & 0 deletions tests/testing.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
provider "azurerm" {
features {}
}

run "setup" {
module {
source = "./tests/environment"
}
}

variables {}

run "plan" {
command = plan

variables {
name = run.setup.workspace_id
resource_group_name = run.setup.resource_group_name
location = run.setup.resource_group_location
}

assert {
condition = azurerm_key_vault.vault.name == run.setup.workspace_id
error_message = "The route table name input variable is being modified."
}

assert {
condition = azurerm_key_vault.vault.resource_group_name == run.setup.resource_group_name
error_message = "The route table resource group input variable is being modified."
}

assert {
condition = azurerm_key_vault.vault.location == run.setup.resource_group_location
error_message = "The route table location input variable is being modified."
}
}

run "apply" {
command = apply

variables {
name = run.setup.workspace_id
resource_group_name = run.setup.resource_group_name
location = run.setup.resource_group_location
}
}

0 comments on commit ffdb0e1

Please sign in to comment.