Skip to content

Commit

Permalink
#43 Add test for isAlreadyLatestVersion
Browse files Browse the repository at this point in the history
Co-Authored-By: Sandra Parsick <[email protected]>
  • Loading branch information
georgberky and sparsick committed Oct 5, 2022
1 parent 98343cd commit e0e66ed
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface GitProvider : AutoCloseable {
fun commit(author: String, email: String, message: String)
fun push(localBranchName: String)
fun checkoutInitialBranch()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ abstract class VersionUpdate(
println("latestVersion.equals(version) = ${latestVersion.equals(version)}")
return latestVersion != "null" && latestVersion != version
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.github.georgberky.maven.plugins.depsupdate

import org.assertj.core.api.Assertions.assertThat
import org.jsoup.nodes.Document
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.Arguments.arguments
import org.junit.jupiter.params.provider.MethodSource
import java.util.stream.Stream

internal class VersionUpdateTest {
@ParameterizedTest
@MethodSource("sameVersionUpdates")
fun `is latest version returns true if version numbers are the same`(current: String, latest: String) {
val versionUpdate = object : VersionUpdate("someGroupId", "someArtifactId", current, latest) {
override fun updatedPom(): Document {
throw Exception("should not be called")
}
}

assertThat(versionUpdate.isAlreadyLatestVersion())
.isTrue()
}

@ParameterizedTest
@MethodSource("differentVersionUpdates")
fun `is latest version returns false if version numbers differ`(current: String, latest: String) {
val versionUpdate = object : VersionUpdate("someGroupId", "someArtifactId", current, latest) {
override fun updatedPom(): Document {
throw Exception("should not be called")
}
}

assertThat(versionUpdate.isAlreadyLatestVersion())
.isFalse()
}

companion object {
@JvmStatic
fun sameVersionUpdates(): Stream<Arguments> {
return Stream.of(
arguments("1.0.0", "1.0.0"),
arguments("1.1.0", "1.1.0"),
arguments("1.0.1", "1.0.1"),
)
}

@JvmStatic
fun differentVersionUpdates(): Stream<Arguments> {
return Stream.of(
arguments("1.0.0", "2.0.0"),
arguments("1.1.0", "2.1.0"),
arguments("1.0.1", "2.0.1"),
)
}
}
}

0 comments on commit e0e66ed

Please sign in to comment.