Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ddb mapper tests #1453

Merged
merged 12 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ kotlinx.atomicfu.enableJvmIrTransformation=true
kotlinx.atomicfu.enableNativeIrTransformation=false

# https://github.com/google/ksp/blob/main/docs/ksp2.md
ksp.useKSP2=true
# Disable KSP2 due to a bug around subsequent invocations
# https://github.com/google/dagger/issues/4181 / https://github.com/google/ksp/issues/1678
ksp.useKSP2=false
9 changes: 5 additions & 4 deletions hll/dynamodb-mapper/dynamodb-mapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ kotlin {
commonTest {
dependencies {
implementation(libs.kotlinx.coroutines.test)
implementation(libs.kotest.assertions.core)
implementation(libs.kotest.runner.junit5)
}
}

jvmTest {
dependencies {
implementation(libs.mockk)
implementation(libs.kotest.assertions.core)
implementation(libs.kotest.runner.junit5)
}
}
}
Expand All @@ -67,8 +67,9 @@ ksp {
}

if (project.NATIVE_ENABLED) {
// Configure KSP for commonMain source generation; https://github.com/google/ksp/issues/963#issuecomment-1894144639

// Configure KSP for multiplatform: https://kotlinlang.org/docs/ksp-multiplatform.html
// https://github.com/google/ksp/issues/963#issuecomment-1894144639
// https://github.com/google/ksp/issues/965
dependencies.kspCommonMainMetadata(project(":hll:dynamodb-mapper:dynamodb-mapper-ops-codegen"))

kotlin.sourceSets.commonMain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.expressions

import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr
import aws.smithy.kotlin.runtime.ExperimentalApi
import kotlin.jvm.JvmName

/**
* A DSL interface providing support for "low-level" filter expressions. Implementations of this interface provide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.LiteralExprImpl
import aws.sdk.kotlin.hll.dynamodbmapper.util.attr
import aws.sdk.kotlin.services.dynamodb.model.AttributeValue
import aws.smithy.kotlin.runtime.ExperimentalApi
import kotlin.jvm.JvmName

/**
* Represents an expression that consists of a single literal value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package aws.sdk.kotlin.hll.dynamodbmapper.expressions

import aws.smithy.kotlin.runtime.ExperimentalApi
import kotlin.jvm.JvmName

/**
* Represents a sort key independent of schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import aws.sdk.kotlin.services.dynamodb.withConfig
import aws.smithy.kotlin.runtime.businessmetrics.emitBusinessMetric
import aws.smithy.kotlin.runtime.client.RequestInterceptorContext
import aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor
import aws.smithy.kotlin.runtime.io.use

internal data class DynamoDbMapperImpl(
override val client: DynamoDbClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import aws.sdk.kotlin.hll.dynamodbmapper.model.internal.ItemImpl
import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr
import aws.sdk.kotlin.services.dynamodb.model.AttributeValue
import aws.smithy.kotlin.runtime.ExperimentalApi
import kotlin.jvm.JvmName

/**
* An immutable representation of a low-level item in a DynamoDB table. Items consist of attributes, each of which have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package aws.sdk.kotlin.hll.dynamodbmapper.util

import aws.sdk.kotlin.services.dynamodb.model.AttributeValue
import kotlin.jvm.JvmName

internal val NULL_ATTR = AttributeValue.Null(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public object TextConverters {
/**
* Converts between [CharArray] and [String]
*/
public val CharArrayToStringConverter: Converter<CharArray, String> = Converter(::String, String::toCharArray)
public val CharArrayToStringConverter: Converter<CharArray, String> = Converter(CharArray::concatToString, String::toCharArray)

/**
* Converts between [Char] and [String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemConverter
import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema
import aws.sdk.kotlin.hll.dynamodbmapper.items.KeySpec
import aws.sdk.kotlin.hll.dynamodbmapper.model.Item
import org.junit.jupiter.api.assertThrows
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

class KeyFilterTest {
private val singleKeySchema = ItemSchema(DummyConverter, KeySpec.String("primary"))
Expand All @@ -31,7 +31,7 @@ class KeyFilterTest {
fun testSingleKeySchemaWithErroneousSortKey() {
val kf = KeyFilter("foo") { sortKey eq 2 }

assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
kf.toExpression(singleKeySchema)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package aws.sdk.kotlin.hll.dynamodbmapper.values
import aws.sdk.kotlin.hll.dynamodbmapper.util.attr
import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr
import aws.sdk.kotlin.services.dynamodb.model.AttributeValue
import kotlin.jvm.JvmName
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ScalarConvertersTest : ValueConvertersTest() {
@Test
fun testByteArrayConverter() = given(ByteArrayConverter) {
byteArrayOf() inDdbIs theSame
"Foo".toByteArray() inDdbIs theSame
"Foo".encodeToByteArray() inDdbIs theSame
ByteArray(1024) { it.toByte() } inDdbIs theSame
}

Expand Down
Loading