From 0c0ebff71adb99eff0e77f0274009c97e5541a7d Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Thu, 14 Sep 2023 08:59:28 -0400 Subject: [PATCH] PR FIXUP - CollectionNamed 1703 test split --- .../one_to_many/with_alias_test.go | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) 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..d5277e2d12 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, @@ -205,13 +205,58 @@ func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_GQL( executeTestCase(t, test) } +// Note: This test should probably not pass, as it contains a +// reference to a document that doesnt exist. +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" @@ -219,7 +264,6 @@ func TestMutationUpdateOneToMany_InvalidAliasRelationNameToLinkFromManySide_Coll 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{ @@ -262,7 +306,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 +359,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,