Open
Conversation
init() runs during package initialization, even when building test binaries. This causes conflicts with the testing framework's flags (e.g., -test.v, -test.paniconexit0). By moving flag parsing to parseFlags() and calling it from main(), flag.Parse() only runs when executing the binary, not during test compilation. This unblocks adding tests for the main package. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Adam Cmiel <acmiel@redhat.com>
Implements "snapshot testing" for dockerfile-json CLI output. Tests are discovered from testdata/ directories containing a Containerfile. Use UPDATE_TESTDATA=1 to regenerate the output files (expected.json). Key design choices: - Tests execute the actual binary - Preserves deterministic key order from struct field serialization - Simple directory structure makes adding tests trivial 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Adam Cmiel <acmiel@redhat.com>
Replace simple JSON dump with go-cmp diff output for clearer test failures. Shows only the differences instead of dumping both full JSONs. Note: compares the JSONs as strings instead of unmarshalling and doing a deep equality check on the objects. This results in more human-friendly diffs. It works because the dockerfile-json output has deterministic key order and because the tests preserve that key order by only using json.Indent instead of doing Unmarshal->Marshal round tripping. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Adam Cmiel <acmiel@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Over at https://github.com/konflux-ci/dockerfile-json, we've been continuing the the development of dockerfile-json (in the dev branch for now, hoping that we could get our fixes merged upstream as well)
To make that easier, we added a testing framework in konflux-ci#6. I think it would be valuable to have upstream as well, hence this PR :)
Note: most of the added lines are from adding
go-cmpto the vendor directory