Skip to content

Commit

Permalink
add mechanism to access common test data during both jvm and mocha ba…
Browse files Browse the repository at this point in the history
…sed testing

rename commonTest/data to commonTest/resources to be process as test resources by the kotlin/Js compiler.
Add wrapper for test resources directory path for common testing
  • Loading branch information
lorenzHeinrich committed Sep 6, 2024
1 parent f19c24a commit fbd78e0
Show file tree
Hide file tree
Showing 227 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ fun assertContentNotEquals(a: ByteArray, b: ByteArray, message: String? = null)
assertFalse(a.contentEquals(b), message)
}

expect val testResourcesDir: String

fun generateRangeChaumPedersenProofKnownNonce(
context: GroupContext
): ChaumPedersenRangeProofKnownNonce {
Expand Down
13 changes: 13 additions & 0 deletions egklib/src/commonTest/kotlin/electionguard/core/UtilsKommTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package electionguard.core

import kotlin.test.Test
import kotlin.test.assertTrue

class UtilsKommTest {
private val testData = "$testResourcesDir/fakeBallots"

@Test
fun accessResources() {
assertTrue { pathExists(testData) }
}
}
3 changes: 3 additions & 0 deletions egklib/src/jsTest/kotlin/electionguard/core/TestHelpers.js.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package electionguard.core

actual val testResourcesDir = "kotlin"
13 changes: 8 additions & 5 deletions egklib/src/jsTest/kotlin/electionguard/core/UtilsKommTest.js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import kotlin.test.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class UtilsKommTest {

companion object {
const val TEST_RESOURCES_DIR = "src/jsTest/resources"
}
class UtilsKommTestJs {

@Test
fun testSimpleFileOperations() {
Expand Down Expand Up @@ -45,4 +41,11 @@ class UtilsKommTest {
}
}

@Test
fun accessResources() {
// the processed resources are put in kotlin subdirectory of the working directory
// build/js/packages/electionguard-kotlin-multiplatform-egklib-test
assertTrue { pathExists("kotlin/testFile.txt") }
}

}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package electionguard.core

actual val testResourcesDir = "src/commonTest/resources"

0 comments on commit fbd78e0

Please sign in to comment.