commit | b276f32545875517927a5cdb754b539c54a94a35 | [log] [tgz] |
---|---|---|
author | Edwin Kempin <ekempin@google.com> | Tue Apr 13 15:50:01 2021 +0200 |
committer | Edwin Kempin <ekempin@google.com> | Wed Apr 14 11:09:18 2021 +0200 |
tree | 758e7dba24b9bf47fd0d20dba476edd3c19b5873 | |
parent | 709353ea07f399a2eb61357bbef7e7bcac0e1410 [diff] |
Simplify the assertion of file code owner statuses For each assertion of a file code owner status we have to check a bunch of properties (old path, code owner status for old path, new path, code owner status for new path, change type), which results in a quite verbose code block that is not very readable. File code owner statuses are asserted in many tests and having this code block that often badly affects the readability of the tests. To improve this we add helper methods that make it easy to create the expected file code owner statuses. Then we can easily compare the actual file code owner statuses with the expected file code owner statuses in a single line. Since we are comparing AutoValue entities, it's automatically checking all the properties. Example: old: FileCodeOwnerStatusSubject fileCodeOwnerStatusSubject = assertThatCollection(fileCodeOwnerStatuses).onlyElement(); fileCodeOwnerStatusSubject.hasOldPathStatus().value().hasPathThat() .isEqualTo(oldPath); fileCodeOwnerStatusSubject .hasOldPathStatus() .value() .hasStatusThat() .isEqualTo(CodeOwnerStatus.INSUFFICIENT_REVIEWERS); fileCodeOwnerStatusSubject.hasNewPathStatus().value().hasPathThat() .isEqualTo(newPath); fileCodeOwnerStatusSubject .hasNewPathStatus() .value() .hasStatusThat() .isEqualTo(CodeOwnerStatus.INSUFFICIENT_REVIEWERS); fileCodeOwnerStatusSubject.hasChangedFile().isRename(); fileCodeOwnerStatusSubject.hasChangedFile().isNoDeletion(); new: assertThatCollection(fileCodeOwnerStatuses) .containsExactly( FileCodeOwnerStatus.rename( oldPath, CodeOwnerStatus.INSUFFICIENT_REVIEWERS, newPath, CodeOwnerStatus.INSUFFICIENT_REVIEWERS)); This change doesn't migrate all tests to the new pattern yet, but at least it's a start to clean this up. Change-Id: I7068fae9dfe6d8e75a1b44cc7e3fd3de0434d7ad Signed-off-by: Edwin Kempin <ekempin@google.com>
This plugin provides support for defining code owners for files in a repository.
If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.
Also see resources/Documentation/about.md.
IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md.