Skip to content

Commit

Permalink
chore: more test cases. (#51571)
Browse files Browse the repository at this point in the history
  • Loading branch information
tryangul authored Jan 15, 2025
1 parent 1358a7c commit 3f57e5f
Showing 1 changed file with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import io.airbyte.cdk.load.command.DestinationStream
import io.airbyte.cdk.load.command.object_storage.ObjectStoragePathConfiguration
import io.airbyte.cdk.load.command.object_storage.ObjectStoragePathConfigurationProvider
import io.airbyte.cdk.load.file.TimeProvider
import io.airbyte.cdk.load.file.object_storage.ObjectStoragePathFactory.Companion.DEFAULT_FILE_FORMAT
import io.airbyte.cdk.load.file.object_storage.ObjectStoragePathFactory.Companion.DEFAULT_PATH_FORMAT
import io.airbyte.cdk.load.file.object_storage.ObjectStoragePathFactory.Companion.DEFAULT_STAGING_PREFIX_SUFFIX
import io.airbyte.cdk.load.state.object_storage.ObjectStorageDestinationState.Companion.OPTIONAL_ORDINAL_SUFFIX_PATTERN
import io.mockk.every
import io.mockk.impl.annotations.MockK
Expand Down Expand Up @@ -122,6 +125,8 @@ class ObjectStoragePathFactoryUTest {
@ParameterizedTest
@MethodSource("pathTemplateMatrix")
fun `handles duplicate vars in path templates`(
namespace: String?,
name: String,
bucketPathTemplate: String,
filePathTemplate: String,
fileNameTemplate: String,
Expand All @@ -137,7 +142,7 @@ class ObjectStoragePathFactoryUTest {
false,
)
val stream = mockk<DestinationStream>()
every { stream.descriptor } returns DestinationStream.Descriptor("namespace1", "stream_abc")
every { stream.descriptor } returns DestinationStream.Descriptor(namespace, name)
val factory = ObjectStoragePathFactory(pathConfigProvider, null, null, timeProvider)

val matcher = factory.getPathMatcher(stream, OPTIONAL_ORDINAL_SUFFIX_PATTERN)
Expand All @@ -153,40 +158,95 @@ class ObjectStoragePathFactoryUTest {
private fun pathTemplateMatrix(): Stream<Arguments> {
return Stream.of(
Arguments.arguments(
"namespace1",
"stream_abc",
"\${NAMESPACE}/\${STREAM_NAME}",
"\${YEAR}/\${MONTH}/\${DAY}/\${NAMESPACE}_\${BIRD_DOG}_\${STREAM_NAME}_\${YEAR}_\${MONTH}_\${DAY}_\${EPOCH}_",
"{part_number}{format_extension}",
"namespace1/stream_abc/2024/08/30/namespace1_BIRD_DOG_stream_abc_2024_08_30_1736900845782_1",
1L,
),
Arguments.arguments(
"namespace1",
"stream_abc",
"\${NAMESPACE}/\${STREAM_NAME}",
"\${YEAR}/\${MONTH}/\${DAY}/\${NAMESPACE}_\${STREAM_NAME}_\${YEAR}_\${MONTH}_\${DAY}_\${EPOCH}_",
"{part_number}{format_extension}",
"namespace1/stream_abc/2024/08/30/namespace1_stream_abc_2024_08_30_1736900845782_5",
5L,
),
Arguments.arguments(
"namespace1",
"stream_abc",
"\${NAMESPACE}/\${STREAM_NAME}",
"\${YEAR}/\${MONTH}/\${DAY}/\${NAMESPACE}_\${STREAM_NAME}_\${YEAR}_\${MONTH}_\${DAY}_\${EPOCH}_",
"{part_number}{format_extension}",
"namespace1/stream_abc/2024/08/30/namespace1_stream_abc_2024_08_30_1736900845782_7",
7L,
),
Arguments.arguments(
"namespace3",
"stream_456",
"\${NAMESPACE}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}",
"_",
"{part_number}{format_extension}",
"namespace1/stream_abc/stream_abc/stream_abc/stream_abc/_0",
"namespace3/stream_456/stream_456/stream_456/stream_456/_0",
0,
),
Arguments.arguments(
"namespace2",
"stream_123",
"\${NAMESPACE}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}",
"",
"{part_number}{format_extension}",
"namespace2/stream_123/stream_123/stream_123/stream_1230",
0,
),
Arguments.arguments(
"namespace1",
"stream_abc",
"\${NAMESPACE}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}",
"",
"{part_number}{format_extension}",
"namespace1/stream_abc/stream_abc/stream_abc/stream_abc0",
0,
),
Arguments.arguments(
null,
"stream_abc",
"asdf",
"\${NAMESPACE}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}",
"{part_number}{format_extension}",
"asdf/stream_abc/stream_abc/stream_abc/stream_abc0",
0,
),
Arguments.arguments(
null,
"stream_abc",
"",
"\${NAMESPACE}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}/\${STREAM_NAME}",
"{part_number}{format_extension}",
"/stream_abc/stream_abc/stream_abc/stream_abc6",
6,
),
Arguments.arguments(
"namespace_2",
"stream_abcd",
"",
DEFAULT_PATH_FORMAT,
DEFAULT_FILE_FORMAT,
"namespace_2/stream_abcd/2024_08_30_1736900845782_7",
7,
),
Arguments.arguments(
"namespace_2",
"stream_abcd",
DEFAULT_STAGING_PREFIX_SUFFIX,
DEFAULT_PATH_FORMAT,
DEFAULT_FILE_FORMAT,
"__airbyte_tmp/namespace_2/stream_abcd/2024_08_30_1736900845782_7",
7,
),
)
}
}
Expand Down

0 comments on commit 3f57e5f

Please sign in to comment.