Skip to content

Commit

Permalink
Add tests documenting existing behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Jun 28, 2024
1 parent e5ff02c commit c1ebad5
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/integration/schema/one_many_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,66 @@ func TestSchemaOneMany_Primary(t *testing.T) {

testUtils.ExecuteTestCase(t, test)
}

func TestSchemaOneMany_SelfReferenceOneFieldLexographicallyFirst(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type User {
a: User
b: [User]
}
`,
ExpectedError: "relation missing field. Object: User, RelationName: user_user",
},
},
}

testUtils.ExecuteTestCase(t, test)
}

func TestSchemaOneMany_SelfReferenceManyFieldLexographicallyFirst(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type User {
b: User
a: [User]
}
`,
ExpectedResults: []client.CollectionDescription{
{
Name: immutable.Some("User"),
Fields: []client.CollectionFieldDescription{
{
Name: "_docID",
},
{
Name: "a",
ID: 1,
Kind: immutable.Some[client.FieldKind](client.ObjectArrayKind("User")),
RelationName: immutable.Some("user_user"),
},
{
Name: "b",
ID: 2,
Kind: immutable.Some[client.FieldKind](client.ObjectKind("User")),
RelationName: immutable.Some("user_user"),
},
{
Name: "b_id",
ID: 3,
Kind: immutable.Some[client.FieldKind](client.ScalarKind(client.FieldKind_DocID)),
RelationName: immutable.Some("user_user"),
},
},
},
},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

0 comments on commit c1ebad5

Please sign in to comment.