Skip to content

Commit

Permalink
cont schema violation subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhanunlu committed Feb 29, 2024
1 parent 8a9d5f8 commit ce4a513
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for acme stuff",
"self": {
"vendor": "com.acme",
"name": "malformed_schema",
"format": "jsonschema",
"version": "1-1-0"
},
"type": "object",
"properties": {
"emailAddress": {
"type": "string"
},
"emailAddress2": {
"type": "string"
},
"emailAddress3": {
"type": "string"
}
},
"required": [],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.snowplowanalytics.snowplow.enrich.common.SpecHelpers._
class IncompleteFailuresSpec extends Specification with CatsEffect {
import IncompleteFailuresSpec._

"failure types" should {
"schema violation types" should {
// mapping error
// collector timestamp

Expand Down Expand Up @@ -64,11 +64,11 @@ class IncompleteFailuresSpec extends Specification with CatsEffect {
}
}

"unstruct data not SDJ" >> {
"criterion mismatch" >> {
val unstruct =
"""
{
"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
"schema":"iglu:com.snowplowanalytics.snowplow/my_unstruct_event/jsonschema/1-0-0",
"data":{
"foo":"bar"
}
Expand All @@ -81,7 +81,7 @@ class IncompleteFailuresSpec extends Specification with CatsEffect {
}
}

"unstruct not found" >> {
"resolution error - schema could not be found in the specified repositories, defined by ResolutionError in the Iglu Client" >> {
val unstruct =
"""
{
Expand All @@ -102,13 +102,30 @@ class IncompleteFailuresSpec extends Specification with CatsEffect {
}
}

"found but invalid" >> {
"validation error - Data is invalid against resolved schema" >> {
val unstruct =
"""
{
"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
"data":{
"foo":"bar"
}
}
"""
enrich(unstruct).map {
case sv: BadRow.SchemaViolations =>
ko(sv.selfDescribingData.asJson.spaces2)
case other => ko(s"[$other] is not a SchemaViolations bad row")
}
}

"validation error - Schema is invalid (empty required list) and cannot be used to validate an instance" >> {
val unstruct =
"""
{
"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
"data":{
"schema":"iglu:com.acme/email_sent/jsonschema/1-0-0",
"schema":"iglu:com.acme/malformed_schema/jsonschema/1-0-0",
"data": {
"foo": "hello@world.com",
"emailAddress2": "foo@bar.org"
Expand Down

0 comments on commit ce4a513

Please sign in to comment.