Skip to content

Commit

Permalink
Units(Terraform): add unit tests for each resource type
Browse files Browse the repository at this point in the history
Close #3683.
  • Loading branch information
Matt Mrowiec authored and masatake committed Mar 29, 2023
1 parent 73de088 commit ef62563
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions Units/parser-terraform.r/data.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example_database_password input.tf /^data "aws_ssm_parameter" "example_database_password" {$/;" d
3 changes: 3 additions & 0 deletions Units/parser-terraform.r/data.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "aws_ssm_parameter" "example_database_password" {
name = "example-database-password"
}
1 change: 1 addition & 0 deletions Units/parser-terraform.r/module.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
database input.tf /^module "database" {$/;" m
3 changes: 3 additions & 0 deletions Units/parser-terraform.r/module.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module "database" {
source = "../../modules/database"
}
1 change: 1 addition & 0 deletions Units/parser-terraform.r/output.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password input.tf /^output "password" {$/;" o
3 changes: 3 additions & 0 deletions Units/parser-terraform.r/output.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "password" {
value = data.aws_ssm_parameter.example_database_password.value
}
1 change: 1 addition & 0 deletions Units/parser-terraform.r/provider.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aws input.tf /^provider "aws" {$/;" p
3 changes: 3 additions & 0 deletions Units/parser-terraform.r/provider.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = "us-east-1"
}
1 change: 1 addition & 0 deletions Units/parser-terraform.r/resource.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example_events_bus input.tf /^resource "aws_cloudwatch_event_bus" "example_events_bus" {$/;" r
3 changes: 3 additions & 0 deletions Units/parser-terraform.r/resource.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "aws_cloudwatch_event_bus" "example_events_bus" {
name = var.events_bus_name
}
1 change: 1 addition & 0 deletions Units/parser-terraform.r/simple-terraform.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
6 changes: 6 additions & 0 deletions Units/parser-terraform.r/simple-terraform.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
aws input.tf /^provider "aws" {$/;" p
events_bus_name input.tf /^variable "events_bus_name" {$/;" v
example_events_bus input.tf /^resource "aws_cloudwatch_event_bus" "example_events_bus" {$/;" r
database input.tf /^module "database" {$/;" m
example_database_password input.tf /^data "aws_ssm_parameter" "example_database_password" {$/;" d
password input.tf /^output "password" {$/;" o
24 changes: 24 additions & 0 deletions Units/parser-terraform.r/simple-terraform.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
provider "aws" {
region = "us-east-1"
}

variable "events_bus_name" {
type = string
default = "hello-world"
}

resource "aws_cloudwatch_event_bus" "example_events_bus" {
name = var.events_bus_name
}

module "database" {
source = "../../modules/database"
}

data "aws_ssm_parameter" "example_database_password" {
name = "example-database-password"
}

output "password" {
value = data.aws_ssm_parameter.example_database_password.value
}
1 change: 1 addition & 0 deletions Units/parser-terraform.r/variable.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
events_bus_name input.tf /^variable "events_bus_name" {$/;" v
4 changes: 4 additions & 0 deletions Units/parser-terraform.r/variable.d/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "events_bus_name" {
type = string
default = "hello-world"
}

0 comments on commit ef62563

Please sign in to comment.