Skip to content

support the azurerm resource-per-folder layout - #153

Open
katbyte wants to merge 3 commits into
mainfrom
kt/resource-folders
Open

katbyte wants to merge 3 commits into
mainfrom
kt/resource-folders

Conversation

@katbyte

@katbyte katbyte commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Find the right tests for azurerm's resource-per-folder layout (<service>/resources/<folder>/resource.go, r_*.go, data_source.go, ...) in both API and AST mode.

Why: azurerm has moved over 300 resources into folders whose files no longer carry the resource's name, so tctest saw every one as a helper and /test triggered nothing.

  • A file in a resource folder belongs to that resource: data_source.go, list.go and action.go run their own tests, anything else runs every test in the folder.
  • Changes to shared packages are traced into resource folders, and API mode lists folders at the PR's merge commit, so folders a PR creates are seen.
  • A folder's test_helpers_test.go and its migration/ package run the folder's tests. A package nested in a folder is always a helper, whatever the file is called and whatever --fileregex matches, since azurerm's regex matches everything under resources/ and its migrations may be named *_resource.go.

The flat layout is unchanged. Integration tests cover each case in both modes with azurerm's real regex; tests, lint, depscheck and typos pass.

…r migration changes

A change to only a resource folder's test_helpers_test.go found no tests: it holds the configs the folder's tests build on but no tests of its own. 53 azurerm folders have one. It now counts as part of the resource, so a change runs every test in the folder.

In API mode, a change to a resource folder's migration/ package found no tests either: the test prefix was guessed from the migration's file name (feature_resource_v0_to_v1.go to feature_resource), which no file in the folder starts with. Inside a resource folder it is now every test in that folder. AST mode already found them by following resource.go's import.
… a helper, so its folder's tests run in both modes

azurerm's fileregex matches everything under resources/, and its newest refactor PRs name migration files like notification_hub_resource.go. Both turned a folder's migration/ files into resource files with no tests beside them, so a migration-only change triggered nothing in API or AST mode.

A file in a package nested inside a resource folder is now a helper whatever its name or the regex says, the AST resource check asks the classifier instead of re-doing the regex, and the azurerm integration suite runs with azurerm's real regex and gains a migration file named like a resource.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant