Commit Graph
4 Commits
Author SHA1 Message Date
Lucas Bajolet 615c0a1cf2 packer_test: add PackerCommand on TestDirSpec
Instead of manually invoking ts.PackerCommand().UsePluginDir(), we
introduce a new PackerCommand() function on TestDirSpec which
fast-tracks this common use-case.
2024-08-15 14:28:16 -04:00
Lucas Bajolet 465ec8bae0 packer_test: make PluginTestDir a structure
In order for the creation of a temporary directory to install plugins
into to be simpler to understand and use, we change how the directory is
created, cleaned-up, and installs plugins into.

Now, instead of a tuple of a string (path) and a cleanup function, we
return a structure that comprises the test suite, and the temporary
directory, along with methods to handle those steps independently.
2024-08-15 14:09:33 -04:00
Lucas Bajolet e91558f4d4 packer_test: hide run and introduce Output
When using a PackerCommand, the Run function was made public as a way to
access the contents of an execution.

This was clumsy as it had too many responsabilities, and was not needed
strictly as Assert was performing the executions, as many times as
required.

This could introduce cases in which one run as spent by the caller, then
the remainder were executed through Assert.

Therefore, we change this convention.

Now, run is private to the type, and only through Assert can a command
be executed.
If a test needs access to a command's output, stderr, or error, it can
do so through the Output function, which requires Assert to be called
first.
2024-08-15 10:51:30 -04:00
Lucas Bajolet c3ef682a8b packer_test: rename/split lib into common/check
The lib name for the common components for writing packer_test suites
was not clear, and did not follow the convention established in Packer
core and plugins.
Therefore this commit does two things: first the lib is renamed into
common as to follow this convention, and clearly document which
components are common to all tests.
Also checkers are placed in a subpackage of common, common/check, so
that it is clearer what is meant to be used as checks for a command's
execution status after it's been run, as part of Assert.
2024-08-15 10:05:27 -04:00