acctest: Gadgets for testing files#13231
Merged
lbajolet-hashicorp merged 2 commits intomainfrom Dec 16, 2024
Merged
Conversation
Some tests will create files and directories as part of the execution path for Packer, and we need a way to check this, so this commit adds a new file gadget to do those checks after a command executes.
When trying to validate that a particular file exists after a run of Packer in a test suite, we can use the FileExists checker that we provide as part of the gadgets we added for the acceptance test suites. This approach works well, but only if we can extract a file name reliably from the output of Packer core, or if we know what to look for exactly beforehand. For other cases with a generated name however, the FileExists checker is not enough, and therefore to accomodate for those cases, we are introducing a new checker for this purpose: FileGlob. FileGlob, as its name suggests, runs a glob expression on the filesystem, and returns an error if no match was found regarding this glob expression.
mogrogan
approved these changes
Dec 16, 2024
Collaborator
mogrogan
left a comment
There was a problem hiding this comment.
I see it's not currently used and probably going to be in followings PRs
LGTM
Contributor
Author
|
Yep, the plan is to have those merged already, so we don't have a dependency problem when/if we revisit those, as that code will already have been merged into main! Thanks for the approval, merging this now! |
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR adds two new checkers to the acceptance testing library, related to files; those gadgets have been extracted from two open PRs: