forked from georgberky/dependency-update-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
georgberky#9 start error handling tests
Co-Authored-By: Sandra Parsick <[email protected]>
- Loading branch information
1 parent
d8221e2
commit 3b17d4c
Showing
2 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/kotlin/com/github/helpermethod/NativeGitProviderErrorHandlingTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.helpermethod | ||
|
||
import org.assertj.core.api.Assertions.assertThatCode | ||
import org.assertj.core.api.Assertions.assertThatThrownBy | ||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.io.TempDir | ||
import java.io.File | ||
|
||
internal class NativeGitProviderErrorHandlingTest { | ||
|
||
private var processOutput: String = "" | ||
private var returnValue: Int = 0 | ||
private lateinit var gitProvider: NativeGitProvider | ||
|
||
@TempDir | ||
lateinit var tempDir: File | ||
|
||
@BeforeEach | ||
internal fun setUp() { | ||
gitProvider = object : NativeGitProvider(tempDir.toPath()) { | ||
override fun runInProcessWithOutput(vararg command: String): Pair<Int, String> { | ||
return Pair(returnValue, processOutput) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
internal fun `error handling`() { | ||
returnValue = -1 | ||
|
||
val callAdd = { gitProvider.add("") } | ||
|
||
assertThatThrownBy(callAdd) | ||
.isInstanceOf(NativeGitProvider.ProcessException::class.java) | ||
.hasMessageContaining("return value") | ||
.hasMessageContaining("-1") | ||
.hasMessageContaining("git add") | ||
} | ||
} | ||
|