Skip to content

Commit

Permalink
Maven: add tests for settings.xml
Browse files Browse the repository at this point in the history
Actually, SonarQube told us we were 0.4% low on test coverage 😅

But it was right: Testing if the settingsXml is only set when using repos or mirrors should have been done.

Co-authored-by: Yannick Christian Thomas <[email protected]>
  • Loading branch information
schnatterer and yannickchristhomas committed May 2, 2024
1 parent 4a98c1e commit ad8e523
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/com/cloudogu/ces/cesbuildlib/MavenTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ class MavenTest {
def result = mvn "test"
assertEquals("test", result)
}

@Test
void testWithoutSettingsXml() throws Exception {
def result = mvn "test"
assert !(mvn.createCommandLineArgs ('dont care')).contains('settings.xml')
assertEquals("test", result)
}

@Test
void testCallWithMirrors() throws Exception {
mvn.useMirrors([name: 'n1', mirrorOf: 'm1', url: 'u1'],
[name: 'n2', mirrorOf: 'm2', url: 'u2'])

assert (mvn.createCommandLineArgs ('dont care')).contains('settings.xml')

def result = mvn "test"

Expand All @@ -58,7 +67,7 @@ class MavenTest {
assert actualSettingsXml.contains(expectedXml)
}
}

@Test
void testCallWithCredentials() throws Exception {
mvn.useRepositoryCredentials([id: 'id', credentialsId: 'creds'])
Expand Down Expand Up @@ -310,6 +319,8 @@ class MavenTest {

mvn.useRepositoryCredentials(repos.toArray(new Map[0]))
methodUnderTest.call()

assert (mvn.createCommandLineArgs ('dont care')).contains('settings.xml')

def repoIds = []
for (int i = 0; i < repos.size(); i++) {
Expand Down

0 comments on commit ad8e523

Please sign in to comment.