Skip to content

Commit

Permalink
corpus: Add two known failure cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sam boyer committed May 11, 2023
1 parent a47c724 commit 17c503b
Show file tree
Hide file tree
Showing 5 changed files with 398 additions and 0 deletions.
1 change: 1 addition & 0 deletions encoding/gocode/gocode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestGenerate(t *testing.T) {
"lineage/defaultchange": "default backcompat invariants not working properly yet",
"lineage/optional": "Optional fields do not satisfy struct.MinFields(), causing #Lineage constraints to fail",
"lineage/union": "Test is abominably slow, cue evaluator is choking up on disjunctions",
"lineage/unifyref": "CUE Struct unifications are not being properly rendered as Go struct embeddings",
},
}

Expand Down
1 change: 1 addition & 0 deletions lineage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestInvalidLineages(t *testing.T) {
"invalidlineage/defaultchange": "Thema compat analyzer fails to classify changes to default values as breaking",
"invalidlineage/joindef": "no invariant checker written to disallow definitions from joinSchema",
"invalidlineage/onlydef": "Lineage schema non-emptiness constraints are temporarily suspended while migrating grafana to flattened lineage structure",
"invalidlineage/addremove": "Required field addition is not detected as breaking changes",
},
}

Expand Down
44 changes: 44 additions & 0 deletions testdata/invalidlineage/addremove.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# adding or removing a required field is considered a backwards incompatible change
#lineagePath: lin
-- in.cue --

import "github.com/grafana/thema"

lin: thema.#Lineage
lin: name: "breaking"
lin: schemas: [{
version: [0, 0]
schema: {
firstfield: string
}
},
{
version: [0, 1]
schema: {
firstfield: string
added: int32
}
},
{
version: [0, 2]
schema: {
firstfield: string
}
}]

lin: lenses: [{
from: [0, 1]
to: [0, 0]
input: _
result: {
firstfield: input.firstfield
}
}, {
from: [0, 2]
to: [0, 2]
input: _
result: {
firstfield: input.firstfield
secondfield: 42
}
}]
1 change: 1 addition & 0 deletions testdata/lineage/basic-multiversion.txtar
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Basic schema evolution over time

#multiversion
#slow
-- in.cue --
import "github.com/grafana/thema"

Expand Down
Loading

0 comments on commit 17c503b

Please sign in to comment.