Skip to content

Commit

Permalink
Add E2E tests for ephemeral values and marked dynamic blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Jan 5, 2025
1 parent ccab0bf commit c04628c
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 44 deletions.
4 changes: 2 additions & 2 deletions integrationtest/inspection/inspection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ func TestIntegration(t *testing.T) {
Dir: "eval-on-root-context",
},
{
Name: "sensitive variable",
Name: "marked values",
Command: "tflint --format json",
Dir: "sensitive",
Dir: "marked",
},
{
Name: "just attributes",
Expand Down
48 changes: 48 additions & 0 deletions integrationtest/inspection/marked/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
variable "no_marked" {
default = "t2.micro"
}

variable "sensitive" {
sensitive = true
default = "t2.micro"
}

variable "ephemeral" {
ephemeral = true
default = "t2.micro"
}

variable "marked_set" {
sensitive = true
default = [true]
}

resource "aws_instance" "no_marked" {
instance_type = var.no_marked
}

resource "aws_instance" "sensitive" {
instance_type = var.sensitive
}

resource "aws_instance" "ephemeral" {
instance_type = var.ephemeral
}

resource "aws_s3_bucket" "main" {
dynamic "lifecycle_rule" {
for_each = var.marked_set

content {
enabled = lifecycle_rule.value
}
}

dynamic "lifecycle_rule" {
for_each = var.marked_set

content {
enabled = true
}
}
}
85 changes: 85 additions & 0 deletions integrationtest/inspection/marked/result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"issues": [
{
"rule": {
"name": "aws_instance_example_type",
"severity": "error",
"link": ""
},
"message": "instance type is t2.micro",
"range": {
"filename": "main.tf",
"start": {
"line": 21,
"column": 19
},
"end": {
"line": 21,
"column": 32
}
},
"callers": []
},
{
"rule": {
"name": "aws_s3_bucket_example_lifecycle_rule",
"severity": "error",
"link": ""
},
"message": "`lifecycle_rule` block found",
"range": {
"filename": "main.tf",
"start": {
"line": 33,
"column": 3
},
"end": {
"line": 33,
"column": 27
}
},
"callers": []
},
{
"rule": {
"name": "aws_s3_bucket_example_lifecycle_rule",
"severity": "error",
"link": ""
},
"message": "`lifecycle_rule` block found",
"range": {
"filename": "main.tf",
"start": {
"line": 41,
"column": 3
},
"end": {
"line": 41,
"column": 27
}
},
"callers": []
},
{
"rule": {
"name": "aws_s3_bucket_example_lifecycle_rule",
"severity": "error",
"link": ""
},
"message": "`enabled` attribute found: true",
"range": {
"filename": "main.tf",
"start": {
"line": 45,
"column": 17
},
"end": {
"line": 45,
"column": 21
}
},
"callers": []
}
],
"errors": []
}
17 changes: 0 additions & 17 deletions integrationtest/inspection/sensitive/main.tf

This file was deleted.

25 changes: 0 additions & 25 deletions integrationtest/inspection/sensitive/result.json

This file was deleted.

0 comments on commit c04628c

Please sign in to comment.