Skip to content

Commit

Permalink
Merge pull request #17 from lukerops/feat/adiciona-teste-group-by-kind
Browse files Browse the repository at this point in the history
Corrige agrupamento do output final, adicionando group by [<kind>][<name>]
  • Loading branch information
lukerops authored Sep 23, 2024
2 parents 89d5d96 + eeb2445 commit ffe6a38
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion groupResources/groupByKind/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ locals {

output "kinds" {
value = {
for kind, result in local.kinds : kind => {
for kind in local.kinds : kind => {
for resource in var.resources : resource.metadata.name => resource
if resource.apiGroup == var.apiGroup && resource.kind == kind
}
Expand Down
21 changes: 21 additions & 0 deletions tests/test_output_by_apigroup.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,25 @@ run "valida_output_por_apigroup" {
condition = length(keys(module.groupResources.groupedResources)) == 1
error_message = "Deveria haver apenas um apigroup: gcp.iam"
}

}

run "valida_output_por_kind" {
command = plan
variables {
yamls = [
"tests/fixtures/user.gcp.iam.crd.yaml",
"tests/fixtures/user.gcp.iam.manifest.yaml",
]
}


assert {
condition = length(
keys(
try(module.groupResources.groupedResources["gcp.iam"]["User"], {})
)
) == 2
error_message = "Não agrupou pelo kind User"
}
}

0 comments on commit ffe6a38

Please sign in to comment.