-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from supabase-community/moshi-jackson-test
Add tests for moshi & jackson serializers
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 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
25 changes: 25 additions & 0 deletions
25
serializers/Jackson/src/commonTest/kotlin/JacksonSerializerTest.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,25 @@ | ||
import io.github.jan.supabase.encode | ||
import io.github.jan.supabase.serializer.JacksonSerializer | ||
import io.github.jan.supabase.testing.createMockedSupabaseClient | ||
import kotlin.reflect.typeOf | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class JacksonSerializerTest { | ||
|
||
@Test | ||
fun testJacksonSerializer() { | ||
val serializer = JacksonSerializer() | ||
val supabaseClient = createMockedSupabaseClient( | ||
configuration = { | ||
defaultSerializer = serializer | ||
} | ||
) | ||
assertEquals(serializer,supabaseClient.defaultSerializer) | ||
val value = mapOf("key" to "value") | ||
val encoded = serializer.encode(value) | ||
val decoded = serializer.decode<Map<String, String>>(typeOf<Map<String, String>>(), encoded) | ||
assertEquals(value, decoded) | ||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
serializers/Moshi/src/commonTest/kotlin/MoshiSerializerTest.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,25 @@ | ||
import io.github.jan.supabase.encode | ||
import io.github.jan.supabase.serializer.MoshiSerializer | ||
import io.github.jan.supabase.testing.createMockedSupabaseClient | ||
import org.junit.Test | ||
import kotlin.reflect.typeOf | ||
import kotlin.test.assertEquals | ||
|
||
class MoshiSerializerTest { | ||
|
||
@Test | ||
fun testMoshiSerializer() { | ||
val serializer = MoshiSerializer() | ||
val supabaseClient = createMockedSupabaseClient( | ||
configuration = { | ||
defaultSerializer = serializer | ||
} | ||
) | ||
assertEquals(serializer, supabaseClient.defaultSerializer) | ||
val value = mapOf("key" to "value") | ||
val encoded = serializer.encode(value) | ||
val decoded = serializer.decode<Map<String, String>>(typeOf<Map<String, String>>(), encoded) | ||
assertEquals(value, decoded) | ||
} | ||
|
||
} |