-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shared layer logic for consistent output and unit testing (#327)
* Let rust-analyzer reorder use statements There was a newline preventing rust-analyzer from ordering the `use` statements. I removed it, and saved and this is the outcome. * Move metadata diff logic into a shared trait * Extract invalid_metadata_action to shared module * Extract restored_layer_action to shared module * Bundle default cache behavior into shared module * Ensure we don't forget to write new metdata * Apply clippy suggestion * Add a test for metadata differences * Handle case where metadata is invalid It might be safe to `expect` in the specific case, but not in the general one. We can return a nicely formatted string with information if it ever happens. * Assert desired caching behavior Instead of asserting implementation (that diffing a metadata object returns a vec entry), assert the behavior we want (that it clears the cache). * Clippy * Use standardized output * Add tests to shared layer cache logic To fully exercise all caching logic in the shared folder, I'm introducing a helper to create a temporary `BuildContext` that can be used for exercising caching logic in test. This also introduces tests for both `restored_layer_action` states as called through `cached_layer_write_metadata`. Which should address this comment #327 (comment). * Assert the behavior of invalid_metadata_action * Exercise same interface used in file In the ruby_install_layer we're exercising `cached_layer_write_metadata` but we were testing `restored_layer_action` which is called currently but might not be in the future via refactoring. This change asserts the behavior we want while using the exact same interface we are currently using. * Combine distro name and version in changed output * Add helper for removing ANSI codes for testing * Format distribution values as backticks with color * Assert all difference output - Ensures each of these cases where the vec is not empty will clear the cache. - Makes it easier for reviewers to see the output as a user would see it.
- Loading branch information
Showing
4 changed files
with
445 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.