diff --git a/tests/integration/mutation/update/field_kinds/one_to_many/with_alias_test.go b/tests/integration/mutation/update/field_kinds/one_to_many/with_alias_test.go index 46d4eb6f32..d1ceb342d7 100644 --- a/tests/integration/mutation/update/field_kinds/one_to_many/with_alias_test.go +++ b/tests/integration/mutation/update/field_kinds/one_to_many/with_alias_test.go @@ -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, @@ -211,14 +211,13 @@ func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_GQL( // 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_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.CollectionNamedMutationType, testUtils.CollectionSaveMutationType, }), Actions: []any{ @@ -255,6 +254,49 @@ func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_Coll executeTestCase(t, test) } +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, + }), + 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: "no document for the given key exists", + }, + }, + } + + executeTestCase(t, test) +} + func TestMutationUpdateOneToMany_AliasRelationNameToLinkFromManySideWithWrongField_Error(t *testing.T) { author1Key := "bae-2edb7fdd-cad7-5ad4-9c7d-6920245a96ed" author2Key := "bae-35953caf-4898-518d-9e6b-9ce6cd86ebe5" @@ -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, @@ -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,