-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8ac626
commit 29bf442
Showing
4 changed files
with
127 additions
and
6 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
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
99 changes: 99 additions & 0 deletions
99
...les/loader/src/test/scala/com/snowplowanalytics/snowplow/rdbloader/db/MigrationSpec.scala
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,99 @@ | ||
package com.snowplowanalytics.snowplow.rdbloader.db | ||
|
||
import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaVer} | ||
import com.snowplowanalytics.snowplow.rdbloader.common.cloud.BlobStorage | ||
import com.snowplowanalytics.snowplow.rdbloader.common.LoaderMessage.SnowplowEntity | ||
import com.snowplowanalytics.snowplow.rdbloader.discovery.ShreddedType | ||
import org.specs2.mutable.Specification | ||
|
||
class MigrationSpec extends Specification { | ||
|
||
"getMaxSchemaKeyPerTableName" should { | ||
"ignore non-tsv & detect max schema key per table name" in { | ||
val shreddedTypes = List( | ||
ShreddedType.Tabular( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"some_context", | ||
SchemaVer.Full(2, 0, 0), | ||
SnowplowEntity.Context | ||
) | ||
), | ||
ShreddedType.Tabular( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"some_context", | ||
SchemaVer.Full(2, 1, 0), | ||
SnowplowEntity.Context | ||
) | ||
), | ||
ShreddedType.Json( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"some_event", | ||
SchemaVer.Full(1, 0, 0), | ||
SnowplowEntity.Context | ||
), | ||
BlobStorage.Key.coerce("s3://shredded/jsonpaths") | ||
) | ||
) | ||
|
||
val result = Migration.getMaxSchemaKeyPerTableName(shreddedTypes) | ||
|
||
result must beEqualTo(Map(("com_acme_some_context_2", SchemaKey("com.acme", "some_context", "jsonschema", SchemaVer.Full(2, 1, 0))))) | ||
} | ||
|
||
"detect max schema key for all table names" in { | ||
val shreddedTypes = List( | ||
ShreddedType.Tabular( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"some_context", | ||
SchemaVer.Full(2, 0, 0), | ||
SnowplowEntity.Context | ||
) | ||
), | ||
ShreddedType.Tabular( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"some_context", | ||
SchemaVer.Full(2, 0, 1), | ||
SnowplowEntity.Context | ||
) | ||
), | ||
ShreddedType.Tabular( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"example", | ||
SchemaVer.Full(1, 0, 0), | ||
SnowplowEntity.Context | ||
) | ||
), | ||
ShreddedType.Tabular( | ||
ShreddedType.Info( | ||
BlobStorage.Folder.coerce("s3://shredded/archive"), | ||
"com.acme", | ||
"example", | ||
SchemaVer.Full(1, 1, 0), | ||
SnowplowEntity.Context | ||
) | ||
) | ||
) | ||
|
||
val result = Migration.getMaxSchemaKeyPerTableName(shreddedTypes) | ||
|
||
result must beEqualTo( | ||
Map( | ||
("com_acme_some_context_2", SchemaKey("com.acme", "some_context", "jsonschema", SchemaVer.Full(2, 0, 1))), | ||
("com_acme_example_1", SchemaKey("com.acme", "example", "jsonschema", SchemaVer.Full(1, 1, 0))) | ||
) | ||
) | ||
} | ||
} | ||
} |
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