Skip to content

Commit

Permalink
PR FIXUP - CollectionNamed 1703 test split
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Sep 14, 2023
1 parent 5851441 commit 254ae3e
Showing 1 changed file with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_GQL(
test := testUtils.TestCase{
Description: "One to many update mutation using relation alias name from many side",
// This restiction is temporary due to a bug in the collection api, see
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_Collection
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_CollectionNamed
// and https://github.com/sourcenetwork/defradb/issues/1703 for more info.
SupportedMutationTypes: immutable.Some([]testUtils.MutationType{
testUtils.GQLRequestMutationType,
Expand Down Expand Up @@ -205,21 +205,63 @@ func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_GQL(
executeTestCase(t, test)
}

func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_CollectionSave(t *testing.T) {
author1Key := "bae-2edb7fdd-cad7-5ad4-9c7d-6920245a96ed"
invalidAuthorKey := "bae-35953ca-518d-9e6b-9ce6cd00eff5"

test := testUtils.TestCase{
Description: "One to many update mutation using relation alias name from many side",
SupportedMutationTypes: immutable.Some([]testUtils.MutationType{
testUtils.CollectionSaveMutationType,
}),
Actions: []any{
testUtils.CreateDoc{
CollectionID: 1,
Doc: `{
"name": "John Grisham"
}`,
},
testUtils.CreateDoc{
CollectionID: 0,
Doc: fmt.Sprintf(
`{
"name": "Painted House",
"author": "%s"
}`,
author1Key,
),
},
testUtils.UpdateDoc{
CollectionID: 0,
DocID: 0,
Doc: fmt.Sprintf(
`{
"author": "%s"
}`,
invalidAuthorKey,
),
ExpectedError: "The given field does not exist. Name: author",
},
},
}

executeTestCase(t, test)
}

// Note: This test should probably not pass, as it contains a
// reference to a document that doesnt exist.
//
// This test also documents a bug in the collection api, see:
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_GQL
// and https://github.com/sourcenetwork/defradb/issues/1703 for more info.
func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_Collection(t *testing.T) {
func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_CollectionNamed(t *testing.T) {
author1Key := "bae-2edb7fdd-cad7-5ad4-9c7d-6920245a96ed"
invalidAuthorKey := "bae-35953ca-518d-9e6b-9ce6cd00eff5"

test := testUtils.TestCase{
Description: "One to many update mutation using relation alias name from many side",
SupportedMutationTypes: immutable.Some([]testUtils.MutationType{
testUtils.CollectionNamedMutationType,
testUtils.CollectionSaveMutationType,
}),
Actions: []any{
testUtils.CreateDoc{
Expand Down Expand Up @@ -262,7 +304,7 @@ func TestMutationUpdateOneToMany_AliasRelationNameToLinkFromManySideWithWrongFie
test := testUtils.TestCase{
Description: "One to many update mutation using relation alias name from many side, with a wrong field.",
// This restiction is temporary due to a bug in the collection api, see
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_Collection
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_CollectionNamed
// and https://github.com/sourcenetwork/defradb/issues/1703 for more info.
SupportedMutationTypes: immutable.Some([]testUtils.MutationType{
testUtils.GQLRequestMutationType,
Expand Down Expand Up @@ -315,7 +357,7 @@ func TestMutationUpdateOneToMany_AliasRelationNameToLinkFromManySide(t *testing.
test := testUtils.TestCase{
Description: "One to many update mutation using relation alias name from many side",
// This restiction is temporary due to a bug in the collection api, see
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_Collection
// TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_CollectionNamed
// and https://github.com/sourcenetwork/defradb/issues/1703 for more info.
SupportedMutationTypes: immutable.Some([]testUtils.MutationType{
testUtils.GQLRequestMutationType,
Expand Down

0 comments on commit 254ae3e

Please sign in to comment.