Skip to content
Snippets Groups Projects
Commit ad8c01e3 authored by Benedikt Wetzel's avatar Benedikt Wetzel Committed by Sören Henning
Browse files

Add test for getResultFolderString

parent e0269474
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!138Load execution ID from file,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -25,9 +25,12 @@ dependencies { ...@@ -25,9 +25,12 @@ dependencies {
implementation 'io.quarkus:quarkus-kubernetes-client' implementation 'io.quarkus:quarkus-kubernetes-client'
implementation 'org.apache.kafka:kafka-clients:2.7.0' implementation 'org.apache.kafka:kafka-clients:2.7.0'
implementation 'khttp:khttp:1.0.0' implementation 'khttp:khttp:1.0.0'
compile 'junit:junit:4.12'
testImplementation 'io.quarkus:quarkus-junit5' testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured' testImplementation 'io.rest-assured:rest-assured'
testImplementation 'org.junit-pioneer:junit-pioneer:1.4.0'
} }
group 'theodolite' group 'theodolite'
......
...@@ -2,10 +2,14 @@ package theodolite.util ...@@ -2,10 +2,14 @@ package theodolite.util
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import io.quarkus.test.junit.QuarkusTest import io.quarkus.test.junit.QuarkusTest
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Rule import org.junit.Rule
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.rules.TemporaryFolder import org.junit.rules.TemporaryFolder
import org.junitpioneer.jupiter.ClearEnvironmentVariable
import org.junitpioneer.jupiter.SetEnvironmentVariable
const val FOLDER_URL = "Test-Folder" const val FOLDER_URL = "Test-Folder"
...@@ -13,7 +17,7 @@ const val FOLDER_URL = "Test-Folder" ...@@ -13,7 +17,7 @@ const val FOLDER_URL = "Test-Folder"
internal class IOHandlerTest { internal class IOHandlerTest {
@Rule @Rule
var temporaryFolder = TemporaryFolder() private var temporaryFolder = TemporaryFolder()
@Test @Test
fun testWriteStringToText() { fun testWriteStringToText() {
...@@ -73,4 +77,44 @@ internal class IOHandlerTest { ...@@ -73,4 +77,44 @@ internal class IOHandlerTest {
IOHandler().readFileAsString("${folder.absolutePath}/test-file.json") IOHandler().readFileAsString("${folder.absolutePath}/test-file.json")
) )
} }
// Test the function `getResultFolderString
@Test
@ClearEnvironmentVariable.ClearEnvironmentVariables(
ClearEnvironmentVariable(key = "RESULTS_FOLDER"),
ClearEnvironmentVariable(key = "CREATE_RESULTS_FOLDER")
)
fun testGetResultFolderURL_emptyEnvironmentVars() {
assertEquals("",IOHandler().getResultFolderURL())
}
@Test()
@SetEnvironmentVariable.SetEnvironmentVariables(
SetEnvironmentVariable(key = "RESULTS_FOLDER", value = FOLDER_URL),
SetEnvironmentVariable(key = "CREATE_RESULTS_FOLDER", value = "false")
)
fun testGetResultFolderURL_FolderNotExist() {
try {
IOHandler().getResultFolderURL()
} catch (e: Exception){
assertThat(e.toString(), containsString("Folder not found"));
}
}
@Test()
@SetEnvironmentVariable.SetEnvironmentVariables(
SetEnvironmentVariable(key = "RESULTS_FOLDER", value = FOLDER_URL),
SetEnvironmentVariable(key = "CREATE_RESULTS_FOLDER", value = "true")
)
fun testGetResultFolderURL_CreateFolderIfNotExist() {
assertEquals("$FOLDER_URL/", IOHandler().getResultFolderURL())
}
@Test()
@ClearEnvironmentVariable(key = "RESULTS_FOLDER" )
@SetEnvironmentVariable(key = "CREATE_RESULTS_FOLDER", value = "true")
fun testGetResultFolderURL_CreateFolderButNoFolderGiven() {
assertEquals("", IOHandler().getResultFolderURL())
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment