Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test that check that modules don't output forbidden names #2091

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/inspect/modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,24 @@ func TestMetadataInjectModuleId(t *testing.T) {
})
}
}

func TestOutputForbiddenNames(t *testing.T) {
nowhere := []string{}
allowed := map[string][]string{
// Global blueprint variables we don't want to get overwritten.
"project_id": {"community/modules/project/new-project"},
"labels": nowhere,
"region": nowhere,
"zone": nowhere,
"deployment_name": nowhere,
}
for _, mod := range query(all()) {
t.Run(mod.Source, func(t *testing.T) {
for _, out := range mod.Outputs {
if where, ok := allowed[out.Name]; ok && !slices.Contains(where, mod.Source) {
t.Errorf("forbidden name for output %q", out.Name)
mr0re1 marked this conversation as resolved.
Show resolved Hide resolved
}
}
})
}
}