Repository navigation
Give the validate_files tests an unowned file that exists - #150
Merged
Merged
Conversation
Three tests in validate_files_test.rs named valid_project's ruby/app/unowned.rb, which doesn't exist: valid_project has to validate cleanly, so it has no unowned file. They passed only because a path that doesn't exist is reported as unowned, so they covered that rather than an unowned file, and would have started failing if nonexistent paths were ever skipped, as #126 proposed. They now write ruby/app/unowned.rb into a temp copy of valid_project and stage it. The invalid_project fixture, which #126 pointed them at, has an empty CODEOWNERS, so every file there is reported as unowned and the mixed test couldn't tell an owned file from an unowned one. Each test now checks the whole output, so the mixed test also checks that ruby/app/models/payroll.rb isn't reported.
Merged
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.
Summary
Three tests in
tests/validate_files_test.rsnamedvalid_project/ruby/app/unowned.rb, which doesn't exist.valid_projecthas to validate cleanly, so it has no unowned file. The tests passed only because a path that doesn't exist is reported as unowned, so they covered that case rather than an unowned file.Found by @perryqh in #126.
Why
The tests didn't test what their names say. They would also have started failing if nonexistent paths were ever skipped, as #126 proposed.
Changes
valid_project_with_unowned_filehelper copiesvalid_projectto a temp dir, writesruby/app/unowned.rbthere, and stages it.test_validate_with_unowned_file,test_validate_with_mixed_filesandtest_generate_and_validate_with_unowned_fileuse it.Unowned files detected:\n ruby/app/unowned.rb\n), so the mixed test also checks thatruby/app/models/payroll.rbisn't reported.#126 pointed these tests at
invalid_projectinstead. That fixture's CODEOWNERS is empty, so every file there is reported as unowned, and the mixed test couldn't tell an owned file from an unowned one.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warningsandcargo testpass (306 passed, the 3 existing ignores).validate_filestemporarily changed to skip nonexistent paths, the three old tests fail and the new ones pass.