Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Mar 27, 2024
1 parent 2a684c4 commit cf296f1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void invalidSubprojectPath() throws IOException {
linkReplacements:
- "http://wrong-url.com|my-dependency.de"
""");
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> readConfig());
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, this::readConfig);
assertThat(exception.getMessage(),
startsWith("E-PK-CORE-83: Invalid .project-keeper.yml. The specified path "));
}
Expand All @@ -132,7 +132,7 @@ void invalidSubprojectPath() throws IOException {
@ValueSource(strings = { "excludes:\n - 1: 3", "excludes:\n - 2", "excludes:\n - regex: 2" })
void testInvalidExcludes(final String invalidExcludes) throws IOException {
writeProjectKeeperConfig(invalidExcludes);
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> readConfig());
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, this::readConfig);
assertThat(exception.getMessage(), startsWith("E-PK-CORE-87: Invalid .project-keeper.yml. Invalid value "));
}

Expand All @@ -144,7 +144,7 @@ void incompleteConfig() throws IOException {
linkReplacements:
- "http://wrong-url.com|my-dependency.de"
""");
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> readConfig());
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, this::readConfig);
assertThat(exception.getMessage(),
equalTo("E-PK-CORE-86: Invalid .project-keeper.yml. Missing required property 'sources/path'."));
}
Expand All @@ -162,7 +162,7 @@ void unknownType() throws IOException {
linkReplacements:
- "http://wrong-url.com|my-dependency.de"
""");
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> readConfig());
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, this::readConfig);
assertThat(exception.getMessage(),
equalTo("E-PK-CORE-84: Invalid .project-keeper.yml. Unsupported source type 'unknown'."
+ " Please use one of the supported types: maven, golang, npm."));
Expand Down Expand Up @@ -282,15 +282,15 @@ void configFileMissing() {
@Test
void invalidYamlSyntax() throws IOException {
writeProjectKeeperConfig("{ -");
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> readConfig());
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, this::readConfig);
assertThat(exception.getMessage(), startsWith("E-PK-CORE-85: Invalid .project-keeper.yml."));
}

@Test
void notInProjectRoot() throws IOException {
Files.delete(this.tempDir.resolve(".git"));
writeProjectKeeperConfig("");
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> readConfig());
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, this::readConfig);
assertThat(exception.getMessage(), equalTo("E-PK-CORE-90: Could not find .git directory in project-root '"
+ this.tempDir
+ "'. Known mitigations:\n* Run 'git init'.\n* Make sure that you run project-keeper only in the root directory of the git-repository. If you have multiple projects in that directory, define them in the '.project-keeper.yml'."));
Expand Down

0 comments on commit cf296f1

Please sign in to comment.