Tests: a record read whole or as an operand still points back at itself, and Record under concurrent use
This commit is contained in:
+10
-6
@@ -184,12 +184,16 @@ func TestInlineRecordRejectsOverlappingColumns(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRecordRejectsAColumnReadingItsOwnRecord(t *testing.T) {
|
||||
dir := writeData(t, map[string]string{
|
||||
"person": `{"format":"{first} {last}","first":["Ada","Bo"],"last":["Lovelace","Ek"],"full":"{/person.first} {/person.last}"}`,
|
||||
})
|
||||
f := newGenerator(t, dir, WithSeed(1))
|
||||
if _, err := f.Record("person"); err == nil || !strings.Contains(err.Error(), "points back at this record") {
|
||||
t.Fatalf("a column referencing its own record = %v, want it refused; it would contradict the columns it reads", err)
|
||||
for _, c := range []struct{ name, column string }{
|
||||
{"a path into itself", `"full":"{/person.first} {/person.last}"`},
|
||||
{"the record read whole", `"whole":"{/person}"`},
|
||||
{"the record as an operand", `"up":"{uppercase(/person)}"`},
|
||||
} {
|
||||
person := `{"format":"{first} {last}","first":["Ada","Bo"],"last":["Lovelace","Ek"],` + c.column + `}`
|
||||
f := newGenerator(t, writeData(t, map[string]string{"person": person}), WithSeed(1))
|
||||
if _, err := f.Record("person"); err == nil || !strings.Contains(err.Error(), "points back at this record") {
|
||||
t.Errorf("%s: Record = %v, want it refused; the column would contradict the columns beside it", c.name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user