Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson committed Jul 31, 2024
1 parent ffefe8b commit 57ea235
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions octoterrawiz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ func TestSpreadVariables(t *testing.T) {
t.Fatalf("No variables should have any whitespace around them")
}

// No sensitive variable should have the same name (this is the whole point of spreading)
if lo.ContainsBy(lvsVariable.Variables, func(item *variables.Variable) bool {
return lo.ContainsBy(lvsVariable.Variables, func(item2 *variables.Variable) bool {
return item.IsSensitive && item2.IsSensitive && item != item2 && item.Name == item2.Name
})
}) {
t.Fatalf("No sensitive variables should have the same name")
}

// No sensitive variable should have a scope (this is the whole point of spreading)
if lo.ContainsBy(lvsVariable.Variables, func(item *variables.Variable) bool {
return !item.Scope.IsEmpty()
}) {
t.Fatalf("No sensitive variables should have a scaope")
}

}

return nil
Expand Down Expand Up @@ -329,6 +345,21 @@ func TestProjectSpreadVariables(t *testing.T) {
t.Fatalf("No variables should have any whitespace around them")
}

// No sensitive variable should have the same name (this is the whole point of spreading)
if lo.ContainsBy(variableSet.Variables, func(item *variables.Variable) bool {
return lo.ContainsBy(variableSet.Variables, func(item2 *variables.Variable) bool {
return item.IsSensitive && item2.IsSensitive && item != item2 && item.Name == item2.Name
})
}) {
t.Fatalf("No sensitive variables should have the same name")
}

// No sensitive variable should have a scope (this is the whole point of spreading)
if lo.ContainsBy(variableSet.Variables, func(item *variables.Variable) bool {
return !item.Scope.IsEmpty()
}) {
t.Fatalf("No sensitive variables should have a scaope")
}
}

return nil
Expand Down

0 comments on commit 57ea235

Please sign in to comment.