test(e2e): add helpers to read/write from/to config #396
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.
Prerequisite checklist
make fmt
on your commit series before opening this PR;Description of changes
Part to #370
Allows each test case to have its own ephemeral configuration file, with which it can conveniently interact by reading/writing arbitrary values before executing
kraft
commands.The included tests should be self-explanatory.
(I wrote tests for the test framework, and am currently resisting the urge to post a "yo dawg" meme about it.)
Notes
I originally wanted the
Write()
method to accept a YAML path and a Go value, but figured that avoiding conversions between the Go and YAML type systems was both:The downside is that test authors need to understand how to use yaml.Filters and how they are executed in a yaml.Pipe.
As the number of CLI tests grows, we hopefully will see some patterns emerge and decide to revisit that approach.
I usually advocate for writing unit tests using Go's bare
testing
package, and reserveginkgo
for the more complex behaviour-driven things that require setup and teardown.In this case though, I used
ginkgo
for the unit tests as well. The reason is that the helpers included in the test framework embed a fewginkgo
functions, so it's easier to test them in the context ofginkgo
runs.