fix: make terraform ConvertState fully deterministic (#23459)
All map iterations in ConvertState now use sorted helpers instead of ranging over Go maps directly. Previously only coder_env and coder_script were sorted (via sortedResourcesByType). This extends the pattern to coder_agent, coder_devcontainer, coder_agent_instance, coder_app, coder_metadata, coder_external_auth, and the main resource output list. Also fixes generate.sh writing version.txt to the wrong directory (resources/ instead of testdata/), which caused the Makefile version check to silently desync and trigger unnecessary regeneration. Adds TestConvertStateDeterministic that calls ConvertState 10 times per fixture and asserts byte-identical JSON output without any post-hoc sorting.
This commit is contained in:
committed by
GitHub
parent
56e80b0a27
commit
b23aed034f
@@ -1255,7 +1255,7 @@ coderd/notifications/.gen-golden: $(wildcard coderd/notifications/testdata/*/*.g
|
||||
TZ=UTC go test ./coderd/notifications -run="Test.*Golden$$" -update
|
||||
touch "$@"
|
||||
|
||||
provisioner/terraform/testdata/.gen-golden: $(wildcard provisioner/terraform/testdata/*/*.golden) $(GO_SRC_FILES) $(wildcard provisioner/terraform/*_test.go)
|
||||
provisioner/terraform/testdata/.gen-golden: $(wildcard provisioner/terraform/testdata/*/*.golden) $(wildcard provisioner/terraform/testdata/*/*/*.golden) $(GO_SRC_FILES) $(wildcard provisioner/terraform/*_test.go)
|
||||
TZ=UTC go test ./provisioner/terraform -run="Test.*Golden$$" -update
|
||||
touch "$@"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user