Skip to content

Commit 507b702

Browse files
committed
Add unit tests for configuration
1 parent d84dd3c commit 507b702

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleConfigurationTest.kt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,39 @@ class AffectedModuleConfigurationTest {
233233
fail("Expected to catch an exception")
234234
}
235235

236+
@Test
237+
fun `GIVEN AffectedModuleConfiguration WHEN compareFrom is set to SpecifiedRawCommitSha THEN is SpecifiedRawCommitSha`() {
238+
val specifiedRawCommitSha = "SpecifiedRawCommitSha"
239+
val commitSha = "12345"
240+
241+
config.specifiedRawCommitSha = commitSha
242+
config.compareFrom = specifiedRawCommitSha
243+
244+
val actual = config.compareFrom
245+
assertThat(actual).isEqualTo(specifiedRawCommitSha)
246+
}
247+
248+
@Test
249+
fun `GIVEN AffectedModuleConfiguration WHEN compareFrom is set to SpecifiedRawCommitSha AND specifiedRawCommitSha not defined THEN error thrown`() {
250+
val specifiedRawCommitSha = "SpecifiedRawCommitSha"
251+
252+
try {
253+
config.compareFrom = specifiedRawCommitSha
254+
} catch (e: IllegalArgumentException) {
255+
// THEN
256+
assertThat(e.message).isEqualTo("Provide a Commit SHA for the specifiedRawCommitSha property when using SpecifiedRawCommitSha comparison strategy.")
257+
return
258+
}
259+
}
260+
236261
@Test
237262
fun `GIVEN AffectedModuleConfiguration WHEN compareFrom is set to invalid sha provider THEN exception thrown and value not set`() {
238263
try {
239264
config.compareFrom = "InvalidInput"
240265
fail()
241266
} catch (e: Exception) {
242267
assertThat(e::class).isEqualTo(IllegalArgumentException::class)
243-
assertThat(e.message).isEqualTo("The property configuration compareFrom must be one of the following: PreviousCommit, ForkCommit, SpecifiedBranchCommit, SpecifiedBranchCommitMergeBase")
268+
assertThat(e.message).isEqualTo("The property configuration compareFrom must be one of the following: PreviousCommit, ForkCommit, SpecifiedBranchCommit, SpecifiedBranchCommitMergeBase, SpecifiedRawCommitSha")
244269
assertThat(config.compareFrom).isEqualTo("PreviousCommit")
245270
}
246271
}

0 commit comments

Comments
 (0)