test: cover the driver, transport, and container logic that had none - #497
Open
tas50 wants to merge 1 commit into
Open
test: cover the driver, transport, and container logic that had none#497tas50 wants to merge 1 commit into
tas50 wants to merge 1 commit into
Conversation
Line coverage of lib/ was 85%, and the gaps were not obscure corners: the driver's lazy `default_config` blocks, `default_image`, `default_platform`, `Container#hostname`, `Container#upload`, `Container::Linux#create`, and every public method on the transport were untested. `default_image` and `default_platform` are what makes "a platform name and nothing else" work, which is the first thing the README promises, and nothing asserted that `ubuntu-24.04` becomes `ubuntu:24.04`. The socket default had a spec, but it re-implemented the block inside the spec file and asserted on its own copy, so it would have passed with the driver's block deleted. It now reads the value back off a driver, which is what Test Kitchen does. Coverage of lib/ goes from 85.3% to 94.5%; the driver, the transport, the container base class, and the Linux container are now fully covered. Signed-off-by: Tim Smith <tim@mondoo.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.
Line coverage of
lib/was 85.3%, and the gaps were not obscure corners.What was untested
Driver#default_image,#default_platformubuntu-24.04becomesubuntu:24.04, or thatcentos-7becomescentos:centos7.default_configblocksimage,platform,username,run_command,build_context,instance_name,package_name,socket.Container#hostnameContainer#upload,Container::Linux#createcreatepopulates the state the transport and verifier read; a key missing from it surfaces as a nil far from the cause.#connection,Connection#execute,#upload,#container, and thetemp_dir/username/socketdefaults.Driver#create,#destroy,#container,#wait_for_transport,#verify_dependenciesA spec that was testing itself
describe "socket default config logic"re-implemented the driver'sdefault_config :socketblock inside the spec file and asserted on its own copy:That passes with the driver's block deleted. It now reads the value back off a driver, which is what Test Kitchen does.
Result
(measured with SimpleCov, which is not added to the Gemfile — it was only used to find the gaps)
The remaining gaps are
Container::Windows#executeand threeContainerHelpermethods, which #496 covers, and the InSpec verifier patches, which only run when kitchen-inspec is in the bundle — CI unit tests run withBUNDLE_WITHOUT=development, so they are not loaded there.No production code is changed.
Verification