Skip to content

Commit 7fc4b42

Browse files
committed
also test mixed case stream name
1 parent 8f43ca6 commit 7fc4b42

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/testFixtures/kotlin/io/airbyte/integrations/base/destination/typing_deduping/BaseSqlGeneratorIntegrationTest.kt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,36 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
521521
* Verifies two behaviors:
522522
* 1. The isFinalTableEmpty method behaves correctly during a sync
523523
* 2. Column names with mixed case are handled correctly
524+
* 3. Stream names with mixed case are handled correctly (under the assumption that destinations
525+
* that support this will also handle mixed-case namespaces, because this test is annoying
526+
* to set up with a different namespace).
524527
*
525528
* The first behavior technically should be its own test, but we might as well just throw it
526529
* into a random testcase to avoid running test setup/teardown again.
527530
*/
528531
@Test
529532
@Throws(java.lang.Exception::class)
530533
fun mixedCaseTest() {
534+
fun toMixedCase(s: String): String =
535+
s.mapIndexed { i, c ->
536+
if (i % 2 == 0) {
537+
c
538+
} else {
539+
c.uppercase()
540+
}
541+
}.joinToString(separator = "")
542+
val streamId = sqlGenerator.buildStreamId(
543+
namespace = streamId.originalNamespace,
544+
name = toMixedCase(streamId.originalName),
545+
rawNamespaceOverride = streamId.rawNamespace,
546+
)
547+
val streamConfig = incrementalDedupStream.copy(id = streamId)
548+
531549
// Add case-sensitive columnName to test json path querying
532-
incrementalDedupStream.columns!![generator.buildColumnId("IamACaseSensitiveColumnName")] =
550+
streamConfig.columns[generator.buildColumnId("IamACaseSensitiveColumnName")] =
533551
AirbyteProtocolType.STRING
534552
createRawTable(streamId)
535-
createFinalTable(incrementalDedupStream, "")
553+
createFinalTable(streamConfig, "")
536554
insertRawTableRecords(
537555
streamId,
538556
BaseTypingDedupingTest.readRecords(
@@ -541,16 +559,20 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
541559
)
542560

543561
var initialState =
544-
getOnly(destinationHandler.gatherInitialState(listOf(incrementalDedupStream)))
562+
getOnly(destinationHandler.gatherInitialState(listOf(streamConfig)))
545563
Assertions.assertTrue(
546564
initialState.isFinalTableEmpty,
547565
"Final table should be empty before T+D"
548566
)
567+
Assertions.assertTrue(
568+
initialState.isFinalTablePresent,
569+
"Final table should exist after we create it"
570+
)
549571

550572
executeTypeAndDedupe(
551573
generator,
552574
destinationHandler,
553-
incrementalDedupStream,
575+
streamConfig,
554576
Optional.empty(),
555577
""
556578
)
@@ -563,7 +585,7 @@ abstract class BaseSqlGeneratorIntegrationTest<DestinationState : MinimumDestina
563585
)
564586

565587
initialState =
566-
getOnly(destinationHandler.gatherInitialState(listOf(incrementalDedupStream)))
588+
getOnly(destinationHandler.gatherInitialState(listOf(streamConfig)))
567589
assertFalse(initialState.isFinalTableEmpty, "Final table should not be empty after T+D")
568590
}
569591

0 commit comments

Comments
 (0)