From beaf9d641958b9b59c47c279f59864e2bbe683b9 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 17 Mar 2023 15:36:30 +0100 Subject: [PATCH 01/21] Rename variables --- client/dockey.go | 2 +- db/collection.go | 63 +++++++++++++++++++++++++------------------ merkle/clock/clock.go | 20 +++++++------- merkle/clock/ipld.go | 4 +-- 4 files changed, 50 insertions(+), 39 deletions(-) diff --git a/client/dockey.go b/client/dockey.go index 583c205091..a3991174a5 100644 --- a/client/dockey.go +++ b/client/dockey.go @@ -87,7 +87,7 @@ func (key DocKey) UUID() uuid.UUID { return key.uuid } -// UUID returns the doc key in string form. +// String returns the doc key in string form. func (key DocKey) String() string { buf := make([]byte, 1) binary.PutUvarint(buf, uint64(key.version)) diff --git a/db/collection.go b/db/collection.go index 2f7eb9581f..f8192dedc4 100644 --- a/db/collection.go +++ b/db/collection.go @@ -597,11 +597,13 @@ func (c *collection) CreateMany(ctx context.Context, docs []*client.Document) er return c.commitImplicitTxn(ctx, txn) } -func (c *collection) create(ctx context.Context, txn datastore.Txn, doc *client.Document) error { +func (c *collection) getKeysFromDoc( + doc *client.Document, +) (client.DocKey, core.PrimaryDataStoreKey, error) { // DocKey verification buf, err := doc.Bytes() if err != nil { - return err + return client.DocKey{}, core.PrimaryDataStoreKey{}, err } // @todo: grab the cid Prefix from the DocKey internal CID if available pref := cid.Prefix{ @@ -613,17 +615,26 @@ func (c *collection) create(ctx context.Context, txn datastore.Txn, doc *client. // And then feed it some data doccid, err := pref.Sum(buf) if err != nil { - return err + return client.DocKey{}, core.PrimaryDataStoreKey{}, err } dockey := client.NewDocKeyV0(doccid) - key := c.getPrimaryKeyFromDocKey(dockey) - if key.DocKey != doc.Key().String() { - return NewErrDocVerification(doc.Key().String(), key.DocKey) + primaryKey := c.getPrimaryKeyFromDocKey(dockey) + if primaryKey.DocKey != doc.Key().String() { + return client.DocKey{}, core.PrimaryDataStoreKey{}, + NewErrDocVerification(doc.Key().String(), primaryKey.DocKey) + } + return dockey, primaryKey, nil +} + +func (c *collection) create(ctx context.Context, txn datastore.Txn, doc *client.Document) error { + dockey, primaryKey, err := c.getKeysFromDoc(doc) + if err != nil { + return err } // check if doc already exists - exists, err := c.exists(ctx, txn, key) + exists, err := c.exists(ctx, txn, primaryKey) if err != nil { return err } @@ -659,8 +670,8 @@ func (c *collection) Update(ctx context.Context, doc *client.Document) error { } defer c.discardImplicitTxn(ctx, txn) - dockey := c.getPrimaryKeyFromDocKey(doc.Key()) - exists, err := c.exists(ctx, txn, dockey) + primaryKey := c.getPrimaryKeyFromDocKey(doc.Key()) + exists, err := c.exists(ctx, txn, primaryKey) if err != nil { return err } @@ -699,8 +710,8 @@ func (c *collection) Save(ctx context.Context, doc *client.Document) error { defer c.discardImplicitTxn(ctx, txn) // Check if document already exists with key - dockey := c.getPrimaryKeyFromDocKey(doc.Key()) - exists, err := c.exists(ctx, txn, dockey) + primaryKey := c.getPrimaryKeyFromDocKey(doc.Key()) + exists, err := c.exists(ctx, txn, primaryKey) if err != nil { return err } @@ -728,7 +739,7 @@ func (c *collection) save( // => Set/Publish new CRDT values primaryKey := c.getPrimaryKeyFromDocKey(doc.Key()) links := make([]core.DAGLink, 0) - merge := make(map[string]any) + docProperties := make(map[string]any) for k, v := range doc.Fields() { val, err := doc.GetValueWithField(v) if err != nil { @@ -745,14 +756,14 @@ func (c *collection) save( return cid.Undef, client.NewErrFieldNotExist(k) } - c, _, err := c.saveDocValue(ctx, txn, fieldKey, val) + node, _, err := c.saveDocValue(ctx, txn, fieldKey, val) if err != nil { return cid.Undef, err } if val.IsDelete() { - merge[k] = nil + docProperties[k] = nil } else { - merge[k] = val.Value() + docProperties[k] = val.Value() } // NOTE: We delay the final Clean() call until we know @@ -766,7 +777,7 @@ func (c *collection) save( link := core.DAGLink{ Name: k, - Cid: c.Cid(), + Cid: node.Cid(), } links = append(links, link) } @@ -776,7 +787,7 @@ func (c *collection) save( if err != nil { return cid.Undef, err } - buf, err := em.Marshal(merge) + buf, err := em.Marshal(docProperties) if err != nil { return cid.Undef, nil } @@ -827,8 +838,8 @@ func (c *collection) Delete(ctx context.Context, key client.DocKey) (bool, error } defer c.discardImplicitTxn(ctx, txn) - dsKey := c.getPrimaryKeyFromDocKey(key) - exists, err := c.exists(ctx, txn, dsKey) + primaryKey := c.getPrimaryKeyFromDocKey(key) + exists, err := c.exists(ctx, txn, primaryKey) if err != nil { return false, err } @@ -837,7 +848,7 @@ func (c *collection) Delete(ctx context.Context, key client.DocKey) (bool, error } // run delete, commit if successful - deleted, err := c.delete(ctx, txn, dsKey) + deleted, err := c.delete(ctx, txn, primaryKey) if err != nil { return false, err } @@ -911,8 +922,8 @@ func (c *collection) Exists(ctx context.Context, key client.DocKey) (bool, error } defer c.discardImplicitTxn(ctx, txn) - dsKey := c.getPrimaryKeyFromDocKey(key) - exists, err := c.exists(ctx, txn, dsKey) + primaryKey := c.getPrimaryKeyFromDocKey(key) + exists, err := c.exists(ctx, txn, primaryKey) if err != nil && !errors.Is(err, ds.ErrNotFound) { return false, err } @@ -964,7 +975,7 @@ func (c *collection) saveValueToMerkleCRDT( args ...any) (ipld.Node, uint64, error) { switch ctype { case client.LWW_REGISTER: - datatype, err := c.db.crdtFactory.InstanceWithStores( + merkleCRDT, err := c.db.crdtFactory.InstanceWithStores( txn, core.NewCollectionSchemaVersionKey(c.Schema().VersionID), c.db.events.Updates, @@ -985,11 +996,11 @@ func (c *collection) saveValueToMerkleCRDT( if !ok { return nil, 0, ErrUnknownCRDTArgument } - lwwreg := datatype.(*crdt.MerkleLWWRegister) + lwwreg := merkleCRDT.(*crdt.MerkleLWWRegister) return lwwreg.Set(ctx, bytes) case client.COMPOSITE: key = key.WithFieldId(core.COMPOSITE_NAMESPACE) - datatype, err := c.db.crdtFactory.InstanceWithStores( + merkleCRDT, err := c.db.crdtFactory.InstanceWithStores( txn, core.NewCollectionSchemaVersionKey(c.Schema().VersionID), c.db.events.Updates, @@ -1014,7 +1025,7 @@ func (c *collection) saveValueToMerkleCRDT( if !ok { return nil, 0, ErrUnknownCRDTArgument } - comp := datatype.(*crdt.MerkleCompositeDAG) + comp := merkleCRDT.(*crdt.MerkleCompositeDAG) return comp.Set(ctx, bytes, links) } return nil, 0, ErrUnknownCRDT diff --git a/merkle/clock/clock.go b/merkle/clock/clock.go index b29df33701..44c4d4c98a 100644 --- a/merkle/clock/clock.go +++ b/merkle/clock/clock.go @@ -160,34 +160,34 @@ func (mc *MerkleClock) ProcessNode( children := []cid.Cid{} for _, l := range links { - child := l.Cid - log.Debug(ctx, "Scanning for replacement heads", logging.NewKV("Child", child)) - isHead, err := mc.headset.IsHead(ctx, child) + linkCid := l.Cid + log.Debug(ctx, "Scanning for replacement heads", logging.NewKV("Child", linkCid)) + isHead, err := mc.headset.IsHead(ctx, linkCid) if err != nil { - return nil, NewErrCheckingHead(child, err) + return nil, NewErrCheckingHead(linkCid, err) } if isHead { log.Debug(ctx, "Found head, replacing!") // reached one of the current heads, replace it with the tip // of current branch - err = mc.headset.Replace(ctx, child, root, rootPrio) + err = mc.headset.Replace(ctx, linkCid, root, rootPrio) if err != nil { - return nil, NewErrReplacingHead(child, root, err) + return nil, NewErrReplacingHead(linkCid, root, err) } continue } - known, err := mc.dagstore.Has(ctx, child) + known, err := mc.dagstore.Has(ctx, linkCid) if err != nil { - return nil, NewErrCouldNotFindBlock(child, err) + return nil, NewErrCouldNotFindBlock(linkCid, err) } if known { // we reached a non-head node in the known tree. // This means our root block is a new head log.Debug(ctx, "Adding head") - err := mc.headset.Write(ctx, root, rootPrio) + err := mc.headset.Write(ctx, root, rootPrio) // @todo: optimize: don't write the same value in the loop if err != nil { log.ErrorE( ctx, @@ -201,7 +201,7 @@ func (mc *MerkleClock) ProcessNode( continue } - children = append(children, child) + children = append(children, linkCid) } return children, nil diff --git a/merkle/clock/ipld.go b/merkle/clock/ipld.go index 1190242c43..bbd9bd4e39 100644 --- a/merkle/clock/ipld.go +++ b/merkle/clock/ipld.go @@ -143,8 +143,8 @@ func makeNode(delta core.Delta, heads []cid.Cid) (ipld.Node, error) { // add delta specific links if comp, ok := delta.(core.CompositeDelta); ok { - for _, dlink := range comp.Links() { - if err = nd.AddRawLink(dlink.Name, &ipld.Link{Cid: dlink.Cid}); err != nil { + for _, dagLink := range comp.Links() { + if err = nd.AddRawLink(dagLink.Name, &ipld.Link{Cid: dagLink.Cid}); err != nil { return nil, err } } From a0470f1d9a061437c239276f18de6c369b66913b Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 17 Mar 2023 15:42:25 +0100 Subject: [PATCH 02/21] Switch some tests to use new framework --- .../query/commits/with_dockey_test.go | 294 ++++++++++-------- tests/integration/query/simple/simple_test.go | 2 +- 2 files changed, 158 insertions(+), 138 deletions(-) diff --git a/tests/integration/query/commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go index 0ee866c3ad..e7ffdffb18 100644 --- a/tests/integration/query/commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -39,41 +39,59 @@ func TestQueryCommitsWithUnknownDockey(t *testing.T) { } func TestQueryCommitsWithDockey(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ "Name": "John", "Age": 21 }`, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - }, - { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + }, + { + "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, with links", - Request: `query { + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.Request{ + Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid links { @@ -82,102 +100,119 @@ func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { } } }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "links": []map[string]any{}, - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "links": []map[string]any{}, - }, - { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", - "links": []map[string]any{ + Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "name": "Age", + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "links": []map[string]any{}, }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "name": "Name", + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "links": []map[string]any{}, + }, + { + "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "links": []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "name": "Age", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "name": "Name", + }, + }, }, }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, multiple results", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ "Name": "John", "Age": 21 }`, }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), - }, - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), }, - { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", - "height": int64(2), - }, - { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", - "height": int64(1), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "height": int64(1), + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "height": int64(2), + }, + { + "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "height": int64(1), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (first results includes link._head, second // includes link._Name). func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, multiple results and links", - Request: `query { + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.Request{ + Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid links { @@ -186,69 +221,54 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { } } }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ - "Age": 22 - }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "links": []map[string]any{ + Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "name": "_head", + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "links": []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "name": "_head", + }, + }, }, - }, - }, - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "links": []map[string]any{}, - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "links": []map[string]any{}, - }, - { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", - "links": []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "name": "Age", + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "links": []map[string]any{}, }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", - "name": "_head", + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "links": []map[string]any{}, }, - }, - }, - { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", - "links": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "name": "Age", + "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "links": []map[string]any{ + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "name": "Age", + }, + { + "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "name": "_head", + }, + }, }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "name": "Name", + "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "links": []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "name": "Age", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "name": "Name", + }, + }, }, }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/simple/simple_test.go b/tests/integration/query/simple/simple_test.go index ba25dc08fc..a09234326e 100644 --- a/tests/integration/query/simple/simple_test.go +++ b/tests/integration/query/simple/simple_test.go @@ -76,7 +76,7 @@ func TestQuerySimpleWithAlias(t *testing.T) { func TestQuerySimpleWithMultipleRows(t *testing.T) { test := testUtils.RequestTestCase{ - Description: "Simple query with no filter, mutiple rows", + Description: "Simple query with no filter, multiple rows", Request: `query { users { Name From fccc5030aaa155a678773497d198f391439e74ae Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 17 Mar 2023 15:45:05 +0100 Subject: [PATCH 03/21] Add a new test with dockey prop of commit --- .../query/commits/with_dockey_prop_test.go | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/integration/query/commits/with_dockey_prop_test.go diff --git a/tests/integration/query/commits/with_dockey_prop_test.go b/tests/integration/query/commits/with_dockey_prop_test.go new file mode 100644 index 0000000000..b72aff2861 --- /dev/null +++ b/tests/integration/query/commits/with_dockey_prop_test.go @@ -0,0 +1,59 @@ +// Copyright 2022 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package commits + +import ( + "testing" + + testUtils "github.com/sourcenetwork/defradb/tests/integration" +) + +func TestQueryCommitsWithDockeyProperty(t *testing.T) { + test := testUtils.TestCase{ + Description: "Simple commits query with dockey property", + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.Request{ + Request: `query { + commits { + cid + dockey + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + { + "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + }, + }, + }, + } + + testUtils.ExecuteTestCase(t, []string{"users"}, test) +} From f9da82b22a646487d2a1d1657807537016253903 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Mon, 20 Mar 2023 10:41:44 +0100 Subject: [PATCH 04/21] Rename variable --- planner/commit.go | 66 +++++++++++------------ planner/planner.go | 124 +++++++++++++++++++++---------------------- planner/select.go | 122 +++++++++++++++++++++--------------------- planner/type_join.go | 2 +- 4 files changed, 157 insertions(+), 157 deletions(-) diff --git a/planner/commit.go b/planner/commit.go index 7437580fb9..4022770d1b 100644 --- a/planner/commit.go +++ b/planner/commit.go @@ -27,31 +27,31 @@ type dagScanNode struct { documentIterator docMapper - p *Planner + planner *Planner depthVisited uint64 visitedNodes map[string]bool queuedCids []*cid.Cid - fetcher fetcher.HeadFetcher - spans core.Spans - parsed *mapper.CommitSelect + fetcher fetcher.HeadFetcher + spans core.Spans + commitSelect *mapper.CommitSelect } -func (p *Planner) DAGScan(parsed *mapper.CommitSelect) *dagScanNode { +func (p *Planner) DAGScan(commitSelect *mapper.CommitSelect) *dagScanNode { return &dagScanNode{ - p: p, + planner: p, visitedNodes: make(map[string]bool), queuedCids: []*cid.Cid{}, - parsed: parsed, - docMapper: docMapper{&parsed.DocumentMapping}, + commitSelect: commitSelect, + docMapper: docMapper{&commitSelect.DocumentMapping}, } } -func (p *Planner) CommitSelect(parsed *mapper.CommitSelect) (planNode, error) { - dagScan := p.DAGScan(parsed) - return p.SelectFromSource(&parsed.Select, dagScan, false, nil) +func (p *Planner) CommitSelect(commitSelect *mapper.CommitSelect) (planNode, error) { + dagScan := p.DAGScan(commitSelect) + return p.SelectFromSource(&commitSelect.Select, dagScan, false, nil) } func (n *dagScanNode) Kind() string { @@ -60,11 +60,11 @@ func (n *dagScanNode) Kind() string { func (n *dagScanNode) Init() error { if len(n.spans.Value) == 0 { - if n.parsed.DocKey.HasValue() { - key := core.DataStoreKey{}.WithDocKey(n.parsed.DocKey.Value()) + if n.commitSelect.DocKey.HasValue() { + key := core.DataStoreKey{}.WithDocKey(n.commitSelect.DocKey.Value()) - if n.parsed.FieldName.HasValue() { - field := n.parsed.FieldName.Value() + if n.commitSelect.FieldName.HasValue() { + field := n.commitSelect.FieldName.Value() key = key.WithFieldId(field) } @@ -72,7 +72,7 @@ func (n *dagScanNode) Init() error { } } - return n.fetcher.Start(n.p.ctx, n.p.txn, n.spans, n.parsed.FieldName) + return n.fetcher.Start(n.planner.ctx, n.planner.txn, n.spans, n.commitSelect.FieldName) } func (n *dagScanNode) Start() error { @@ -97,8 +97,8 @@ func (n *dagScanNode) Spans(spans core.Spans) { copy(headSetSpans.Value, spans.Value) var fieldId string - if n.parsed.FieldName.HasValue() { - fieldId = n.parsed.FieldName.Value() + if n.commitSelect.FieldName.HasValue() { + fieldId = n.commitSelect.FieldName.Value() } else { fieldId = core.COMPOSITE_NAMESPACE } @@ -124,15 +124,15 @@ func (n *dagScanNode) Explain() (map[string]any, error) { explainerMap := map[string]any{} // Add the field attribute to the explaination if it exists. - if n.parsed.FieldName.HasValue() { - explainerMap["field"] = n.parsed.FieldName.Value() + if n.commitSelect.FieldName.HasValue() { + explainerMap["field"] = n.commitSelect.FieldName.Value() } else { explainerMap["field"] = nil } // Add the cid attribute to the explaination if it exists. - if n.parsed.Cid.HasValue() { - explainerMap["cid"] = n.parsed.Cid.Value() + if n.commitSelect.Cid.HasValue() { + explainerMap["cid"] = n.commitSelect.Cid.Value() } else { explainerMap["cid"] = nil } @@ -159,7 +159,7 @@ func (n *dagScanNode) Explain() (map[string]any, error) { func (n *dagScanNode) Next() (bool, error) { var currentCid *cid.Cid - store := n.p.txn.DAGstore() + store := n.planner.txn.DAGstore() if len(n.queuedCids) > 0 { currentCid = n.queuedCids[0] @@ -186,7 +186,7 @@ func (n *dagScanNode) Next() (bool, error) { // use the stored cid to scan through the blockstore // clear the cid after - block, err := store.Get(n.p.ctx, *currentCid) + block, err := store.Get(n.planner.ctx, *currentCid) if err != nil { return false, err } @@ -206,7 +206,7 @@ func (n *dagScanNode) Next() (bool, error) { // HEAD paths. n.depthVisited++ n.visitedNodes[currentCid.String()] = true // mark the current node as "visited" - if !n.parsed.Depth.HasValue() || n.depthVisited < n.parsed.Depth.Value() { + if !n.commitSelect.Depth.HasValue() || n.depthVisited < n.commitSelect.Depth.Value() { // Insert the newly fetched cids into the slice of queued items, in reverse order // so that the last new cid will be at the front of the slice n.queuedCids = append(make([]*cid.Cid, len(heads)), n.queuedCids...) @@ -216,7 +216,7 @@ func (n *dagScanNode) Next() (bool, error) { } } - if n.parsed.Cid.HasValue() && currentCid.String() != n.parsed.Cid.Value() { + if n.commitSelect.Cid.HasValue() && currentCid.String() != n.commitSelect.Cid.Value() { // If a specific cid has been requested, and the current item does not // match, keep searching. return n.Next() @@ -264,9 +264,9 @@ All the dagScanNode endpoints use similar structures */ func (n *dagScanNode) dagBlockToNodeDoc(block blocks.Block) (core.Doc, []*ipld.Link, error) { - commit := n.parsed.DocumentMapping.NewDoc() + commit := n.commitSelect.DocumentMapping.NewDoc() cid := block.Cid() - n.parsed.DocumentMapping.SetFirstOfName(&commit, "cid", cid.String()) + n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "cid", cid.String()) // decode the delta, get the priority and payload nd, err := dag.DecodeProtobuf(block.RawData()) @@ -287,20 +287,20 @@ func (n *dagScanNode) dagBlockToNodeDoc(block blocks.Block) (core.Doc, []*ipld.L schemaVersionId, ok := delta["SchemaVersionID"].(string) if ok { - n.parsed.DocumentMapping.SetFirstOfName(&commit, "schemaVersionId", schemaVersionId) + n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "schemaVersionId", schemaVersionId) } - n.parsed.DocumentMapping.SetFirstOfName(&commit, "height", int64(prio)) - n.parsed.DocumentMapping.SetFirstOfName(&commit, "delta", delta["Data"]) + n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "height", int64(prio)) + n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "delta", delta["Data"]) heads := make([]*ipld.Link, 0) // links - linksIndexes := n.parsed.DocumentMapping.IndexesByName[request.LinksFieldName] + linksIndexes := n.commitSelect.DocumentMapping.IndexesByName[request.LinksFieldName] for _, linksIndex := range linksIndexes { links := make([]core.Doc, len(nd.Links())) - linksMapping := n.parsed.DocumentMapping.ChildMappings[linksIndex] + linksMapping := n.commitSelect.DocumentMapping.ChildMappings[linksIndex] for i, l := range nd.Links() { link := linksMapping.NewDoc() diff --git a/planner/planner.go b/planner/planner.go index 91bb669f7c..4a9b53ace7 100644 --- a/planner/planner.go +++ b/planner/planner.go @@ -169,29 +169,29 @@ func (p *Planner) newObjectMutationPlan(stmt *mapper.Mutation) (planNode, error) // an initiated plan. The caller of makePlan is also responsible of calling Close() // on the plan to free it's resources. func (p *Planner) makePlan(stmt any) (planNode, error) { - plan, err := p.newPlan(stmt) + planNode, err := p.newPlan(stmt) if err != nil { return nil, err } - err = p.optimizePlan(plan) + err = p.optimizePlan(planNode) if err != nil { return nil, err } - err = plan.Init() - return plan, err + err = planNode.Init() + return planNode, err } // optimizePlan optimizes the plan using plan expansion and wiring. -func (p *Planner) optimizePlan(plan planNode) error { - err := p.expandPlan(plan, nil) +func (p *Planner) optimizePlan(planNode planNode) error { + err := p.expandPlan(planNode, nil) return err } // expandPlan does a full plan graph expansion and other optimizations. -func (p *Planner) expandPlan(plan planNode, parentPlan *selectTopNode) error { - switch n := plan.(type) { +func (p *Planner) expandPlan(planNode planNode, parentPlan *selectTopNode) error { + switch n := planNode.(type) { case *selectTopNode: return p.expandSelectTopNodePlan(n, parentPlan) @@ -247,12 +247,12 @@ func (p *Planner) expandPlan(plan planNode, parentPlan *selectTopNode) error { } func (p *Planner) expandSelectTopNodePlan(plan *selectTopNode, parentPlan *selectTopNode) error { - if err := p.expandPlan(plan.selectnode, plan); err != nil { + if err := p.expandPlan(plan.selectNode, plan); err != nil { return err } // wire up source to plan - plan.plan = plan.selectnode + plan.planNode = plan.selectNode // if group if plan.group != nil { @@ -260,15 +260,15 @@ func (p *Planner) expandSelectTopNodePlan(plan *selectTopNode, parentPlan *selec if err != nil { return err } - plan.plan = plan.group + plan.planNode = plan.group } p.expandAggregatePlans(plan) // if order if plan.order != nil { - plan.order.plan = plan.plan - plan.plan = plan.order + plan.order.plan = plan.planNode + plan.planNode = plan.order } if plan.limit != nil { @@ -288,13 +288,13 @@ func (p *Planner) expandAggregatePlans(plan *selectTopNode) { // execute *before* any aggregate dependent on them. for i := len(plan.aggregates) - 1; i >= 0; i-- { aggregate := plan.aggregates[i] - aggregate.SetPlan(plan.plan) - plan.plan = aggregate + aggregate.SetPlan(plan.planNode) + plan.planNode = aggregate } } -func (p *Planner) expandMultiNode(plan MultiNode, parentPlan *selectTopNode) error { - for _, child := range plan.Children() { +func (p *Planner) expandMultiNode(multiNode MultiNode, parentPlan *selectTopNode) error { + for _, child := range multiNode.Children() { if err := p.expandPlan(child, parentPlan); err != nil { return err } @@ -312,22 +312,22 @@ func (p *Planner) expandTypeIndexJoinPlan(plan *typeIndexJoin, parentPlan *selec return client.NewErrUnhandledType("join plan", plan.joinPlan) } -func (p *Planner) expandGroupNodePlan(plan *selectTopNode) error { +func (p *Planner) expandGroupNodePlan(topNodeSelect *selectTopNode) error { var sourceNode planNode var hasScanNode bool - // Find the first scan node in the plan, we assume that it will be for the correct collection. + // Find the first scan node in the topNodeSelect, we assume that it will be for the correct collection. // This may be a commit node. - sourceNode, hasScanNode = walkAndFindPlanType[*scanNode](plan.plan) + sourceNode, hasScanNode = walkAndFindPlanType[*scanNode](topNodeSelect.planNode) if !hasScanNode { - commitNode, hasCommitNode := walkAndFindPlanType[*dagScanNode](plan.plan) + commitNode, hasCommitNode := walkAndFindPlanType[*dagScanNode](topNodeSelect.planNode) if !hasCommitNode { return ErrFailedToFindGroupSource } sourceNode = commitNode } - // Check for any existing pipe nodes in the plan, we should use it if there is one - pipe, hasPipe := walkAndFindPlanType[*pipeNode](plan.plan) + // Check for any existing pipe nodes in the topNodeSelect, we should use it if there is one + pipe, hasPipe := walkAndFindPlanType[*pipeNode](topNodeSelect.planNode) if !hasPipe { newPipeNode := newPipeNode(sourceNode.DocumentMap()) @@ -335,35 +335,35 @@ func (p *Planner) expandGroupNodePlan(plan *selectTopNode) error { pipe.source = sourceNode } - if len(plan.group.childSelects) == 0 { - dataSource := plan.group.dataSources[0] - dataSource.parentSource = plan.plan + if len(topNodeSelect.group.childSelects) == 0 { + dataSource := topNodeSelect.group.dataSources[0] + dataSource.parentSource = topNodeSelect.planNode dataSource.pipeNode = pipe } - for i, childSelect := range plan.group.childSelects { + for i, childSelect := range topNodeSelect.group.childSelects { childSelectNode, err := p.SelectFromSource( childSelect, pipe, false, - &plan.selectnode.sourceInfo, + &topNodeSelect.selectNode.sourceInfo, ) if err != nil { return err } - dataSource := plan.group.dataSources[i] + dataSource := topNodeSelect.group.dataSources[i] dataSource.childSource = childSelectNode - dataSource.parentSource = plan.plan + dataSource.parentSource = topNodeSelect.planNode dataSource.pipeNode = pipe } - if err := p.walkAndReplacePlan(plan.group, sourceNode, pipe); err != nil { + if err := p.walkAndReplacePlan(topNodeSelect.group, sourceNode, pipe); err != nil { return err } - for _, dataSource := range plan.group.dataSources { - err := p.expandPlan(dataSource.childSource, plan) + for _, dataSource := range topNodeSelect.group.dataSources { + err := p.expandPlan(dataSource.childSource, topNodeSelect) if err != nil { return err } @@ -372,26 +372,26 @@ func (p *Planner) expandGroupNodePlan(plan *selectTopNode) error { return nil } -func (p *Planner) expandLimitPlan(plan *selectTopNode, parentPlan *selectTopNode) { - if plan.limit == nil { +func (p *Planner) expandLimitPlan(topNodeSelect *selectTopNode, parentPlan *selectTopNode) { + if topNodeSelect.limit == nil { return } // Limits get more complicated with groups and have to be handled internally, so we ensure - // any limit plan is disabled here + // any limit topNodeSelect is disabled here if parentPlan != nil && parentPlan.group != nil && len(parentPlan.group.childSelects) != 0 { - plan.limit = nil + topNodeSelect.limit = nil return } - plan.limit.plan = plan.plan - plan.plan = plan.limit + topNodeSelect.limit.plan = topNodeSelect.planNode + topNodeSelect.planNode = topNodeSelect.limit } // walkAndReplace walks through the provided plan, and searches for an instance // of the target plan, and replaces it with the replace plan -func (p *Planner) walkAndReplacePlan(plan, target, replace planNode) error { - src := plan.Source() +func (p *Planner) walkAndReplacePlan(planNode, target, replace planNode) error { + src := planNode.Source() if src == nil { return nil } @@ -404,7 +404,7 @@ func (p *Planner) walkAndReplacePlan(plan, target, replace planNode) error { // We've found our plan, figure out what type our current plan is // and update accordingly - switch node := plan.(type) { + switch node := planNode.(type) { case *selectNode: node.source = replace case *typeJoinOne: @@ -423,8 +423,8 @@ func (p *Planner) walkAndReplacePlan(plan, target, replace planNode) error { // walkAndFindPlanType walks through the plan graph, and returns the first // instance of a plan, that matches the given type. -func walkAndFindPlanType[T planNode](plan planNode) (T, bool) { - src := plan +func walkAndFindPlanType[T planNode](planNode planNode) (T, bool) { + src := planNode if src == nil { var defaultT T return defaultT, false @@ -432,7 +432,7 @@ func walkAndFindPlanType[T planNode](plan planNode) (T, bool) { targetType, isTargetType := src.(T) if !isTargetType { - return walkAndFindPlanType[T](plan.Source()) + return walkAndFindPlanType[T](planNode.Source()) } return targetType, true @@ -442,12 +442,12 @@ func walkAndFindPlanType[T planNode](plan planNode) (T, bool) { // be executed, maintaing their order in the plan graph (does not actually execute them). func (p *Planner) explainRequest( ctx context.Context, - plan planNode, + planNode planNode, explainType request.ExplainType, ) ([]map[string]any, error) { switch explainType { case request.SimpleExplain: - explainGraph, err := buildSimpleExplainGraph(plan) + explainGraph, err := buildSimpleExplainGraph(planNode) if err != nil { return nil, err } @@ -468,25 +468,25 @@ func (p *Planner) explainRequest( // executeRequest executes the plan graph that represents the request that was made. func (p *Planner) executeRequest( ctx context.Context, - plan planNode, + planNode planNode, ) ([]map[string]any, error) { - if err := plan.Start(); err != nil { + if err := planNode.Start(); err != nil { return nil, err } - next, err := plan.Next() + hasNext, err := planNode.Next() if err != nil { return nil, err } docs := []map[string]any{} - docMap := plan.DocumentMap() + docMap := planNode.DocumentMap() - for next { - copy := docMap.ToMap(plan.Value()) + for hasNext { + copy := docMap.ToMap(planNode.Value()) docs = append(docs, copy) - next, err = plan.Next() + hasNext, err = planNode.Next() if err != nil { return nil, err } @@ -500,13 +500,13 @@ func (p *Planner) RunRequest( ctx context.Context, req *request.Request, ) (result []map[string]any, err error) { - plan, err := p.makePlan(req) + planNode, err := p.makePlan(req) if err != nil { return nil, err } defer func() { - if e := plan.Close(); e != nil { + if e := planNode.Close(); e != nil { err = NewErrFailedToClosePlan(e, "running request") } }() @@ -517,15 +517,15 @@ func (p *Planner) RunRequest( } if len(req.Queries) > 0 && req.Queries[0].Directives.ExplainType.HasValue() { - return p.explainRequest(ctx, plan, req.Queries[0].Directives.ExplainType.Value()) + return p.explainRequest(ctx, planNode, req.Queries[0].Directives.ExplainType.Value()) } if len(req.Mutations) > 0 && req.Mutations[0].Directives.ExplainType.HasValue() { - return p.explainRequest(ctx, plan, req.Mutations[0].Directives.ExplainType.Value()) + return p.explainRequest(ctx, planNode, req.Mutations[0].Directives.ExplainType.Value()) } // This won't / should NOT execute if it's any kind of explain request. - return p.executeRequest(ctx, plan) + return p.executeRequest(ctx, planNode) } // RunSubscriptionRequest plans a request specific to a subscription and returns the result. @@ -533,18 +533,18 @@ func (p *Planner) RunSubscriptionRequest( ctx context.Context, request *request.Select, ) (result []map[string]any, err error) { - plan, err := p.makePlan(request) + planNode, err := p.makePlan(request) if err != nil { return nil, err } defer func() { - if e := plan.Close(); e != nil { + if e := planNode.Close(); e != nil { err = NewErrFailedToClosePlan(e, "running subscription request") } }() - return p.executeRequest(ctx, plan) + return p.executeRequest(ctx, planNode) } // MakePlan makes a plan from the parsed request. diff --git a/planner/select.go b/planner/select.go index 649da2305f..13e4d39f2e 100644 --- a/planner/select.go +++ b/planner/select.go @@ -53,26 +53,26 @@ type selectTopNode struct { limit *limitNode aggregates []aggregateNode - // selectnode is used pre-wiring of the plan (before expansion and all). - selectnode *selectNode + // selectNode is used pre-wiring of the plan (before expansion and all). + selectNode *selectNode // plan is the top of the plan graph (the wired and finalized plan graph). - plan planNode + planNode planNode } func (n *selectTopNode) Kind() string { return "selectTopNode" } -func (n *selectTopNode) Init() error { return n.plan.Init() } +func (n *selectTopNode) Init() error { return n.planNode.Init() } -func (n *selectTopNode) Start() error { return n.plan.Start() } +func (n *selectTopNode) Start() error { return n.planNode.Start() } -func (n *selectTopNode) Next() (bool, error) { return n.plan.Next() } +func (n *selectTopNode) Next() (bool, error) { return n.planNode.Next() } -func (n *selectTopNode) Spans(spans core.Spans) { n.plan.Spans(spans) } +func (n *selectTopNode) Spans(spans core.Spans) { n.planNode.Spans(spans) } -func (n *selectTopNode) Value() core.Doc { return n.plan.Value() } +func (n *selectTopNode) Value() core.Doc { return n.planNode.Value() } -func (n *selectTopNode) Source() planNode { return n.plan } +func (n *selectTopNode) Source() planNode { return n.planNode } // Explain method for selectTopNode returns no attributes but is used to // subscribe / opt-into being an explainablePlanNode. @@ -82,10 +82,10 @@ func (n *selectTopNode) Explain() (map[string]any, error) { } func (n *selectTopNode) Close() error { - if n.plan == nil { + if n.planNode == nil { return nil } - return n.plan.Close() + return n.planNode.Close() } type selectNode struct { @@ -117,7 +117,7 @@ type selectNode struct { docKeys immutable.Option[[]string] - parsed *mapper.Select + selectReq *mapper.Select groupSelects []*mapper.Select } @@ -139,7 +139,7 @@ func (n *selectNode) Start() error { // renders the doc. func (n *selectNode) Next() (bool, error) { for { - if next, err := n.source.Next(); !next { + if hasNext, err := n.source.Next(); !hasNext { return false, err } @@ -196,11 +196,11 @@ func (n *selectNode) Explain() (map[string]any, error) { // the necessary filters. Its designed to work with the // planner.Select construction call. func (n *selectNode) initSource() ([]aggregateNode, error) { - if n.parsed.CollectionName == "" { - n.parsed.CollectionName = n.parsed.Name + if n.selectReq.CollectionName == "" { + n.selectReq.CollectionName = n.selectReq.Name } - sourcePlan, err := n.p.getSource(n.parsed) + sourcePlan, err := n.p.getSource(n.selectReq) if err != nil { return nil, err } @@ -220,25 +220,25 @@ func (n *selectNode) initSource() ([]aggregateNode, error) { // If we have both a DocKey and a CID, then we need to run // a TimeTravel (History-Traversing Versioned) query, which means // we need to propagate the values to the underlying VersionedFetcher - if n.parsed.Cid.HasValue() { - c, err := cid.Decode(n.parsed.Cid.Value()) + if n.selectReq.Cid.HasValue() { + c, err := cid.Decode(n.selectReq.Cid.Value()) if err != nil { return nil, err } spans := fetcher.NewVersionedSpan( - core.DataStoreKey{DocKey: n.parsed.DocKeys.Value()[0]}, + core.DataStoreKey{DocKey: n.selectReq.DocKeys.Value()[0]}, c, ) // @todo check len origScan.Spans(spans) - } else if n.parsed.DocKeys.HasValue() { + } else if n.selectReq.DocKeys.HasValue() { // If we *just* have a DocKey(s), run a FindByDocKey(s) optimization // if we have a FindByDockey filter, create a span for it // and propagate it to the scanNode // @todo: When running the optimizer, check if the filter object // contains a _key equality condition, and upgrade it to a point lookup // instead of a prefix scan + filter via the Primary Index (0), like here: - spans := make([]core.Span, len(n.parsed.DocKeys.Value())) - for i, docKey := range n.parsed.DocKeys.Value() { + spans := make([]core.Span, len(n.selectReq.DocKeys.Value())) + for i, docKey := range n.selectReq.DocKeys.Value() { dockeyIndexKey := base.MakeDocKey(sourcePlan.info.collectionDescription, docKey) spans[i] = core.NewSpan(dockeyIndexKey, dockeyIndexKey.PrefixEnd()) } @@ -246,14 +246,14 @@ func (n *selectNode) initSource() ([]aggregateNode, error) { } } - return n.initFields(n.parsed) + return n.initFields(n.selectReq) } -func (n *selectNode) initFields(parsed *mapper.Select) ([]aggregateNode, error) { +func (n *selectNode) initFields(selectReq *mapper.Select) ([]aggregateNode, error) { aggregates := []aggregateNode{} // loop over the sub type // at the moment, we're only testing a single sub selection - for _, field := range parsed.Fields { + for _, field := range selectReq.Fields { switch f := field.(type) { case *mapper.Aggregate: var plan aggregateNode @@ -261,9 +261,9 @@ func (n *selectNode) initFields(parsed *mapper.Select) ([]aggregateNode, error) switch f.Name { case request.CountFieldName: - plan, aggregateError = n.p.Count(f, parsed) + plan, aggregateError = n.p.Count(f, selectReq) case request.SumFieldName: - plan, aggregateError = n.p.Sum(f, parsed) + plan, aggregateError = n.p.Sum(f, selectReq) case request.AverageFieldName: plan, aggregateError = n.p.Average(f) } @@ -283,14 +283,14 @@ func (n *selectNode) initFields(parsed *mapper.Select) ([]aggregateNode, error) // handle _version sub selection query differently // if we are executing a regular Scan query // or a TimeTravel query. - if parsed.Cid.HasValue() { + if selectReq.Cid.HasValue() { // for a TimeTravel query, we don't need the Latest // commit. Instead, _version references the CID // of that Target version we are querying. // So instead of a LatestCommit subquery, we need // a OneCommit subquery, with the supplied parameters. - commitSlct.DocKey = immutable.Some(parsed.DocKeys.Value()[0]) // @todo check length - commitSlct.Cid = parsed.Cid + commitSlct.DocKey = immutable.Some(selectReq.DocKeys.Value()[0]) // @todo check length + commitSlct.Cid = selectReq.Cid } commitPlan := n.p.DAGScan(commitSlct) @@ -299,7 +299,7 @@ func (n *selectNode) initFields(parsed *mapper.Select) ([]aggregateNode, error) return nil, err } } else if f.Name == request.GroupFieldName { - if parsed.GroupBy == nil { + if selectReq.GroupBy == nil { return nil, ErrGroupOutsideOfGroupBy } n.groupSelects = append(n.groupSelects, f) @@ -341,8 +341,8 @@ func (n *selectNode) Source() planNode { return n.source } // not to be used on the top level selection node. // This allows us to disable rendering on all sub Select nodes // and only run it at the end on the top level select node. -func (p *Planner) SubSelect(parsed *mapper.Select) (planNode, error) { - plan, err := p.Select(parsed) +func (p *Planner) SubSelect(selectReq *mapper.Select) (planNode, error) { + plan, err := p.Select(selectReq) if err != nil { return nil, err } @@ -354,7 +354,7 @@ func (p *Planner) SubSelect(parsed *mapper.Select) (planNode, error) { } func (p *Planner) SelectFromSource( - parsed *mapper.Select, + selectReq *mapper.Select, source planNode, fromCollection bool, providedSourceInfo *sourceInfo, @@ -363,21 +363,21 @@ func (p *Planner) SelectFromSource( p: p, source: source, origSource: source, - parsed: parsed, - docMapper: docMapper{&parsed.DocumentMapping}, - filter: parsed.Filter, - docKeys: parsed.DocKeys, + selectReq: selectReq, + docMapper: docMapper{&selectReq.DocumentMapping}, + filter: selectReq.Filter, + docKeys: selectReq.DocKeys, } - limit := parsed.Limit - orderBy := parsed.OrderBy - groupBy := parsed.GroupBy + limit := selectReq.Limit + orderBy := selectReq.OrderBy + groupBy := selectReq.GroupBy if providedSourceInfo != nil { s.sourceInfo = *providedSourceInfo } if fromCollection { - desc, err := p.getCollectionDesc(parsed.Name) + desc, err := p.getCollectionDesc(selectReq.Name) if err != nil { return nil, err } @@ -385,77 +385,77 @@ func (p *Planner) SelectFromSource( s.sourceInfo = sourceInfo{desc} } - aggregates, err := s.initFields(parsed) + aggregates, err := s.initFields(selectReq) if err != nil { return nil, err } - groupPlan, err := p.GroupBy(groupBy, parsed, s.groupSelects) + groupPlan, err := p.GroupBy(groupBy, selectReq, s.groupSelects) if err != nil { return nil, err } - limitPlan, err := p.Limit(parsed, limit) + limitPlan, err := p.Limit(selectReq, limit) if err != nil { return nil, err } - orderPlan, err := p.OrderBy(parsed, orderBy) + orderPlan, err := p.OrderBy(selectReq, orderBy) if err != nil { return nil, err } top := &selectTopNode{ - selectnode: s, + selectNode: s, limit: limitPlan, order: orderPlan, group: groupPlan, aggregates: aggregates, - docMapper: docMapper{&parsed.DocumentMapping}, + docMapper: docMapper{&selectReq.DocumentMapping}, } return top, nil } // Select constructs a SelectPlan -func (p *Planner) Select(parsed *mapper.Select) (planNode, error) { +func (p *Planner) Select(selectReq *mapper.Select) (planNode, error) { s := &selectNode{ p: p, - filter: parsed.Filter, - docKeys: parsed.DocKeys, - parsed: parsed, - docMapper: docMapper{&parsed.DocumentMapping}, + filter: selectReq.Filter, + docKeys: selectReq.DocKeys, + selectReq: selectReq, + docMapper: docMapper{&selectReq.DocumentMapping}, } - limit := parsed.Limit - orderBy := parsed.OrderBy - groupBy := parsed.GroupBy + limit := selectReq.Limit + orderBy := selectReq.OrderBy + groupBy := selectReq.GroupBy aggregates, err := s.initSource() if err != nil { return nil, err } - groupPlan, err := p.GroupBy(groupBy, parsed, s.groupSelects) + groupPlan, err := p.GroupBy(groupBy, selectReq, s.groupSelects) if err != nil { return nil, err } - limitPlan, err := p.Limit(parsed, limit) + limitPlan, err := p.Limit(selectReq, limit) if err != nil { return nil, err } - orderPlan, err := p.OrderBy(parsed, orderBy) + orderPlan, err := p.OrderBy(selectReq, orderBy) if err != nil { return nil, err } top := &selectTopNode{ - selectnode: s, + selectNode: s, limit: limitPlan, order: orderPlan, group: groupPlan, aggregates: aggregates, - docMapper: docMapper{&parsed.DocumentMapping}, + docMapper: docMapper{&selectReq.DocumentMapping}, } return top, nil } diff --git a/planner/type_join.go b/planner/type_join.go index 00e2be0011..cbca6de0fe 100644 --- a/planner/type_join.go +++ b/planner/type_join.go @@ -365,7 +365,7 @@ func (n *typeJoinOne) valuesPrimary(doc core.Doc) core.Doc { } // create the collection key for the sub doc - slct := n.subType.(*selectTopNode).selectnode + slct := n.subType.(*selectTopNode).selectNode desc := slct.sourceInfo.collectionDescription subKeyIndexKey := base.MakeDocKey(desc, subDocKeyStr) From 7546dccb246536c17ea81f6b96ff7946e155e434 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Mon, 20 Mar 2023 10:42:43 +0100 Subject: [PATCH 05/21] Add dockey field to commit graphql query --- client/request/consts.go | 6 ++++-- db/collection.go | 4 ++-- db/collection_update.go | 2 +- planner/mapper/mapper.go | 6 +++--- request/graphql/schema/collection.go | 8 ++++---- request/graphql/schema/generate.go | 6 +++--- request/graphql/schema/types/commits.go | 4 ++++ 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/client/request/consts.go b/client/request/consts.go index b50e3d113e..dfc68994c5 100644 --- a/client/request/consts.go +++ b/client/request/consts.go @@ -32,7 +32,7 @@ const ( AverageFieldName = "_avg" CountFieldName = "_count" - DocKeyFieldName = "_key" + KeyFieldName = "_key" GroupFieldName = "_group" SumFieldName = "_sum" VersionFieldName = "_version" @@ -46,6 +46,7 @@ const ( LinksFieldName = "links" HeightFieldName = "height" CidFieldName = "cid" + DockeyFieldName = "dockey" SchemaVersionIDFieldName = "schemaVersionId" DeltaFieldName = "delta" @@ -69,7 +70,7 @@ var ( CountFieldName: true, SumFieldName: true, AverageFieldName: true, - DocKeyFieldName: true, + KeyFieldName: true, } Aggregates = map[string]struct{}{ @@ -86,6 +87,7 @@ var ( VersionFields = []string{ HeightFieldName, CidFieldName, + DockeyFieldName, SchemaVersionIDFieldName, DeltaFieldName, } diff --git a/db/collection.go b/db/collection.go index f8192dedc4..4342543627 100644 --- a/db/collection.go +++ b/db/collection.go @@ -67,7 +67,7 @@ func (db *db) newCollection(desc client.CollectionDescription) (*collection, err } docKeyField := desc.Schema.Fields[0] - if docKeyField.Kind != client.FieldKind_DocKey || docKeyField.Name != request.DocKeyFieldName { + if docKeyField.Kind != client.FieldKind_DocKey || docKeyField.Name != request.KeyFieldName { return nil, ErrSchemaFirstFieldDocKey } @@ -309,7 +309,7 @@ func (db *db) validateUpdateCollection( var existingField client.FieldDescription var fieldAlreadyExists bool if proposedField.ID != client.FieldID(0) || - proposedField.Name == request.DocKeyFieldName { + proposedField.Name == request.KeyFieldName { existingField, fieldAlreadyExists = existingFieldsByID[proposedField.ID] } diff --git a/db/collection_update.go b/db/collection_update.go index dc133cd981..61c0cdf611 100644 --- a/db/collection_update.go +++ b/db/collection_update.go @@ -265,7 +265,7 @@ func (c *collection) updateWithFilter( } // add successful updated doc to results - results.DocKeys = append(results.DocKeys, doc[request.DocKeyFieldName].(string)) + results.DocKeys = append(results.DocKeys, doc[request.KeyFieldName].(string)) results.Count++ } diff --git a/planner/mapper/mapper.go b/planner/mapper/mapper.go index 0ad826224a..d3c31deac8 100644 --- a/planner/mapper/mapper.go +++ b/planner/mapper/mapper.go @@ -620,7 +620,7 @@ func getTopLevelInfo( } if selectRequest.Root == request.ObjectSelection { - mapping.Add(core.DocKeyFieldIndex, request.DocKeyFieldName) + mapping.Add(core.DocKeyFieldIndex, request.KeyFieldName) desc, err := descriptionsRepo.getCollectionDesc(collectionName) if err != nil { @@ -695,7 +695,7 @@ func resolveInnerFilterDependencies( newFields := []Requestable{} for key := range source { - if strings.HasPrefix(key, "_") && key != request.DocKeyFieldName { + if strings.HasPrefix(key, "_") && key != request.KeyFieldName { continue } @@ -901,7 +901,7 @@ func toFilterMap( sourceClause any, mapping *core.DocumentMapping, ) (connor.FilterKey, any) { - if strings.HasPrefix(sourceKey, "_") && sourceKey != request.DocKeyFieldName { + if strings.HasPrefix(sourceKey, "_") && sourceKey != request.KeyFieldName { key := &Operator{ Operation: sourceKey, } diff --git a/request/graphql/schema/collection.go b/request/graphql/schema/collection.go index 29666195ab..9d316e18f5 100644 --- a/request/graphql/schema/collection.go +++ b/request/graphql/schema/collection.go @@ -82,7 +82,7 @@ func fromAstDefinition( ) (client.CollectionDescription, error) { fieldDescriptions := []client.FieldDescription{ { - Name: request.DocKeyFieldName, + Name: request.KeyFieldName, Kind: client.FieldKind_DocKey, Typ: client.NONE_CRDT, }, @@ -150,10 +150,10 @@ func fromAstDefinition( // sort the fields lexicographically sort.Slice(fieldDescriptions, func(i, j int) bool { - // make sure that the _key (DocKeyFieldName) is always at the beginning - if fieldDescriptions[i].Name == request.DocKeyFieldName { + // make sure that the _key (KeyFieldName) is always at the beginning + if fieldDescriptions[i].Name == request.KeyFieldName { return true - } else if fieldDescriptions[j].Name == request.DocKeyFieldName { + } else if fieldDescriptions[j].Name == request.KeyFieldName { return false } return fieldDescriptions[i].Name < fieldDescriptions[j].Name diff --git a/request/graphql/schema/generate.go b/request/graphql/schema/generate.go index 3809b98134..07303a0733 100644 --- a/request/graphql/schema/generate.go +++ b/request/graphql/schema/generate.go @@ -370,7 +370,7 @@ func (g *Generator) buildTypes( fields := gql.Fields{} // automatically add the _key: ID field to the type - fields[request.DocKeyFieldName] = &gql.Field{Type: gql.ID} + fields[request.KeyFieldName] = &gql.Field{Type: gql.ID} for _, field := range fieldDescriptions { var ttype gql.Type @@ -970,7 +970,7 @@ func (g *Generator) genTypeFilterArgInput(obj *gql.Object) *gql.InputObject { // generate basic filter operator blocks // @todo: Extract object field loop into its own utility func for f, field := range obj.Fields() { - if _, ok := request.ReservedFields[f]; ok && f != request.DocKeyFieldName { + if _, ok := request.ReservedFields[f]; ok && f != request.KeyFieldName { continue } // scalars (leafs) @@ -1069,7 +1069,7 @@ func (g *Generator) genTypeOrderArgInput(obj *gql.Object) *gql.InputObject { fields := gql.InputObjectConfigFieldMap{} for f, field := range obj.Fields() { - if _, ok := request.ReservedFields[f]; ok && f != request.DocKeyFieldName { + if _, ok := request.ReservedFields[f]; ok && f != request.KeyFieldName { continue } typeMap := g.manager.schema.TypeMap() diff --git a/request/graphql/schema/types/commits.go b/request/graphql/schema/types/commits.go index b7dd74817f..aba5c59b89 100644 --- a/request/graphql/schema/types/commits.go +++ b/request/graphql/schema/types/commits.go @@ -29,6 +29,7 @@ var ( // type Commit { // Height: Int // CID: String + // Dockey: String // SchemaVersionID: String // Delta: String // Previous: [Commit] @@ -46,6 +47,9 @@ var ( "cid": &gql.Field{ Type: gql.String, }, + "dockey": &gql.Field{ + Type: gql.String, + }, "schemaVersionId": &gql.Field{ Type: gql.String, }, From 260a160f7dabd29dcd382da7e7d9b01aa1fe453f Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Tue, 21 Mar 2023 10:45:15 +0100 Subject: [PATCH 06/21] Rename variables --- planner/multi.go | 10 +++++----- planner/select.go | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/planner/multi.go b/planner/multi.go index c158b818bf..02bd4a0fda 100644 --- a/planner/multi.go +++ b/planner/multi.go @@ -385,7 +385,7 @@ func (s *selectNode) addSubPlan(fieldIndex int, plan planNode) error { s.source = plan case appendNode: m := ¶llelNode{ - p: s.p, + p: s.planner, docMapper: docMapper{src.DocumentMap()}, } m.addChild(-1, src) @@ -404,19 +404,19 @@ func (s *selectNode) addSubPlan(fieldIndex int, plan planNode) error { // create our new multiscanner multiscan := &multiScanNode{scanNode: origScan} // replace our current source internal scanNode with our new multiscanner - if err := s.p.walkAndReplacePlan(src, origScan, multiscan); err != nil { + if err := s.planner.walkAndReplacePlan(src, origScan, multiscan); err != nil { return err } // create multinode multinode := ¶llelNode{ - p: s.p, + p: s.planner, multiscan: multiscan, docMapper: docMapper{src.DocumentMap()}, } multinode.addChild(-1, src) multiscan.addReader() // replace our new node internal scanNode with our new multiscanner - if err := s.p.walkAndReplacePlan(plan, origScan, multiscan); err != nil { + if err := s.planner.walkAndReplacePlan(plan, origScan, multiscan); err != nil { return err } // add our newly updated plan to the multinode @@ -439,7 +439,7 @@ func (s *selectNode) addSubPlan(fieldIndex int, plan planNode) error { } // replace our new node internal scanNode with our existing multiscanner - if err := s.p.walkAndReplacePlan(plan, multiscan.Source(), multiscan); err != nil { + if err := s.planner.walkAndReplacePlan(plan, multiscan.Source(), multiscan); err != nil { return err } multiscan.addReader() diff --git a/planner/select.go b/planner/select.go index 13e4d39f2e..59730b70a6 100644 --- a/planner/select.go +++ b/planner/select.go @@ -92,7 +92,7 @@ type selectNode struct { documentIterator docMapper - p *Planner + planner *Planner // main data source for the select node. source planNode @@ -200,7 +200,7 @@ func (n *selectNode) initSource() ([]aggregateNode, error) { n.selectReq.CollectionName = n.selectReq.Name } - sourcePlan, err := n.p.getSource(n.selectReq) + sourcePlan, err := n.planner.getSource(n.selectReq) if err != nil { return nil, err } @@ -261,11 +261,11 @@ func (n *selectNode) initFields(selectReq *mapper.Select) ([]aggregateNode, erro switch f.Name { case request.CountFieldName: - plan, aggregateError = n.p.Count(f, selectReq) + plan, aggregateError = n.planner.Count(f, selectReq) case request.SumFieldName: - plan, aggregateError = n.p.Sum(f, selectReq) + plan, aggregateError = n.planner.Sum(f, selectReq) case request.AverageFieldName: - plan, aggregateError = n.p.Average(f) + plan, aggregateError = n.planner.Average(f) } if aggregateError != nil { @@ -293,7 +293,7 @@ func (n *selectNode) initFields(selectReq *mapper.Select) ([]aggregateNode, erro commitSlct.Cid = selectReq.Cid } - commitPlan := n.p.DAGScan(commitSlct) + commitPlan := n.planner.DAGScan(commitSlct) if err := n.addSubPlan(f.Index, commitPlan); err != nil { return nil, err @@ -314,7 +314,7 @@ func (n *selectNode) initFields(selectReq *mapper.Select) ([]aggregateNode, erro } func (n *selectNode) addTypeIndexJoin(subSelect *mapper.Select) error { - typeIndexJoin, err := n.p.makeTypeIndexJoin(n, n.origSource, subSelect) + typeIndexJoin, err := n.planner.makeTypeIndexJoin(n, n.origSource, subSelect) if err != nil { return err } @@ -334,7 +334,7 @@ func (n *selectNode) Source() planNode { return n.source } // fields []*client.FieldDescription, // aliases []string, //) error { -// return n.p.render(fields, aliases) +// return n.planner.render(fields, aliases) // } // SubSelect is used for creating Select nodes used on sub selections, @@ -360,7 +360,7 @@ func (p *Planner) SelectFromSource( providedSourceInfo *sourceInfo, ) (planNode, error) { s := &selectNode{ - p: p, + planner: p, source: source, origSource: source, selectReq: selectReq, @@ -419,7 +419,7 @@ func (p *Planner) SelectFromSource( // Select constructs a SelectPlan func (p *Planner) Select(selectReq *mapper.Select) (planNode, error) { s := &selectNode{ - p: p, + planner: p, filter: selectReq.Filter, docKeys: selectReq.DocKeys, selectReq: selectReq, From a973fb6c98c67383e69d46ac5b4630d85ce0722f Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Tue, 21 Mar 2023 10:47:30 +0100 Subject: [PATCH 07/21] Add dockey to composite delta block and read it --- core/crdt/composite.go | 5 ++++- planner/commit.go | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/crdt/composite.go b/core/crdt/composite.go index b28f6d2062..0b6c6e678b 100644 --- a/core/crdt/composite.go +++ b/core/crdt/composite.go @@ -39,6 +39,7 @@ type CompositeDAGDelta struct { SchemaVersionID string Priority uint64 Data []byte + DocKey []byte SubDAGs []core.DAGLink } @@ -61,7 +62,8 @@ func (delta *CompositeDAGDelta) Marshal() ([]byte, error) { SchemaVersionID string Priority uint64 Data []byte - }{delta.SchemaVersionID, delta.Priority, delta.Data}) + DocKey []byte + }{delta.SchemaVersionID, delta.Priority, delta.Data, delta.DocKey}) if err != nil { return nil, err } @@ -119,6 +121,7 @@ func (c CompositeDAG) Set(patch []byte, links []core.DAGLink) *CompositeDAGDelta }) return &CompositeDAGDelta{ Data: patch, + DocKey: c.key.Bytes(), SubDAGs: links, SchemaVersionID: c.schemaVersionKey.SchemaVersionId, } diff --git a/planner/commit.go b/planner/commit.go index 4022770d1b..8a6a3cfc2a 100644 --- a/planner/commit.go +++ b/planner/commit.go @@ -41,7 +41,7 @@ type dagScanNode struct { func (p *Planner) DAGScan(commitSelect *mapper.CommitSelect) *dagScanNode { return &dagScanNode{ - planner: p, + planner: p, visitedNodes: make(map[string]bool), queuedCids: []*cid.Cid{}, commitSelect: commitSelect, @@ -293,6 +293,16 @@ func (n *dagScanNode) dagBlockToNodeDoc(block blocks.Block) (core.Doc, []*ipld.L n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "height", int64(prio)) n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "delta", delta["Data"]) + dockey, ok := delta["DocKey"].([]byte) + if ok { + dockeyObj, err := core.NewDataStoreKey(string(dockey)) + if err != nil { + return core.Doc{}, nil, err + } + n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "dockey", + string(dockeyObj.InstanceType)) + } + heads := make([]*ipld.Link, 0) // links From c75f715feeb2c0ff7ed5233e14c1936f3b7bde1a Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Tue, 21 Mar 2023 14:44:34 +0100 Subject: [PATCH 08/21] Adjust existing CIDs in tests --- .../query/one_to_many/with_cid_dockey_test.go | 8 ++++---- tests/integration/query/simple/with_cid_dockey_test.go | 10 +++++----- tests/integration/query/simple/with_version_test.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/integration/query/one_to_many/with_cid_dockey_test.go b/tests/integration/query/one_to_many/with_cid_dockey_test.go index 743d809cdb..8482c26a0d 100644 --- a/tests/integration/query/one_to_many/with_cid_dockey_test.go +++ b/tests/integration/query/one_to_many/with_cid_dockey_test.go @@ -68,7 +68,7 @@ func TestQueryOneToManyWithCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with cid and dockey", Request: `query { book ( - cid: "bafybeictbaivadgsndtnzopt72z446mmg35xvlof45dujfudkjzhwtoqfq", + cid: "bafybeid7tx5fhjcekoly2cckw2kb46buuvqslv5r3hzmcl36ji7o2hhnhi", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name @@ -117,7 +117,7 @@ func TestQueryOneToManyWithChildUpdateAndFirstCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with child update and parent cid and dockey", Request: `query { book ( - cid: "bafybeictbaivadgsndtnzopt72z446mmg35xvlof45dujfudkjzhwtoqfq", + cid: "bafybeid7tx5fhjcekoly2cckw2kb46buuvqslv5r3hzmcl36ji7o2hhnhi", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name @@ -173,7 +173,7 @@ func TestQueryOneToManyWithParentUpdateAndFirstCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with parent update and parent cid and dockey", Request: `query { book ( - cid: "bafybeictbaivadgsndtnzopt72z446mmg35xvlof45dujfudkjzhwtoqfq", + cid: "bafybeid7tx5fhjcekoly2cckw2kb46buuvqslv5r3hzmcl36ji7o2hhnhi", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name @@ -229,7 +229,7 @@ func TestQueryOneToManyWithParentUpdateAndLastCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with parent update and parent cid and dockey", Request: `query { book ( - cid: "bafybeigxbi4aj5s5dqwyuvegncglqf2vbdc3ic5yv5vf72cxetozsdpcca", + cid: "bafybeidaovkvq5yvwolbeugeceyzuut2wqojul44ituacjvemdpqugekwa", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name diff --git a/tests/integration/query/simple/with_cid_dockey_test.go b/tests/integration/query/simple/with_cid_dockey_test.go index d92733fff7..5bd6cefa68 100644 --- a/tests/integration/query/simple/with_cid_dockey_test.go +++ b/tests/integration/query/simple/with_cid_dockey_test.go @@ -73,7 +73,7 @@ func TestQuerySimpleWithCidAndDocKey(t *testing.T) { Description: "Simple query with cid and dockey", Request: `query { users ( - cid: "bafybeieqnthjlvr64aodivtvtwgqelpjjvkmceyz4aqerkk5h23kjoivmu", + cid: "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -102,7 +102,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocKey(t *testing.T) { Description: "Simple query with (first) cid and dockey", Request: `query { users ( - cid: "bafybeieqnthjlvr64aodivtvtwgqelpjjvkmceyz4aqerkk5h23kjoivmu", + cid: "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -143,7 +143,7 @@ func TestQuerySimpleWithUpdateAndLastCidAndDocKey(t *testing.T) { Description: "Simple query with (last) cid and dockey", Request: `query { users ( - cid: "bafybeidktrpyl76uhni7afslprurt44x37boq5mz4b5qavrrkvvbxooc2m", + cid: "bafybeig2exzgeuq2ctwhxyxq4ucosgxanw3nzhodetq2sclo5lvdyavk5m", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -184,7 +184,7 @@ func TestQuerySimpleWithUpdateAndMiddleCidAndDocKey(t *testing.T) { Description: "Simple query with (middle) cid and dockey", Request: `query { users ( - cid: "bafybeier3i4bgyqc57t4lzz2tfien2wdq3jaw3ukcajo6sz5dzxu5layka", + cid: "bafybeibjmbeb6olbio3getfvotoe3l3krljd5pceqbr3cx4nf3o2wv5t54", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -225,7 +225,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocKeyAndSchemaVersion(t *testing.T) Description: "Simple query with (first) cid and dockey and yielded schema version", Request: `query { users ( - cid: "bafybeieqnthjlvr64aodivtvtwgqelpjjvkmceyz4aqerkk5h23kjoivmu", + cid: "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name diff --git a/tests/integration/query/simple/with_version_test.go b/tests/integration/query/simple/with_version_test.go index e28f9e7a2b..95c8313b43 100644 --- a/tests/integration/query/simple/with_version_test.go +++ b/tests/integration/query/simple/with_version_test.go @@ -46,7 +46,7 @@ func TestQuerySimpleWithEmbeddedLatestCommit(t *testing.T) { "Age": uint64(21), "_version": []map[string]any{ { - "cid": "bafybeieqnthjlvr64aodivtvtwgqelpjjvkmceyz4aqerkk5h23kjoivmu", + "cid": "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", "links": []map[string]any{ { "cid": "bafybeihbnch3akfu22wlbq3es7vudxev5ymo2deq2inknxhbpoacd7x5aq", @@ -133,7 +133,7 @@ func TestQuerySimpleWithMultipleAliasedEmbeddedLatestCommit(t *testing.T) { "Age": uint64(21), "_version": []map[string]any{ { - "cid": "bafybeieqnthjlvr64aodivtvtwgqelpjjvkmceyz4aqerkk5h23kjoivmu", + "cid": "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", "L1": []map[string]any{ { "cid": "bafybeihbnch3akfu22wlbq3es7vudxev5ymo2deq2inknxhbpoacd7x5aq", From 2fb968a421029322a794d7e5c8c113366188c61f Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Tue, 21 Mar 2023 15:53:40 +0100 Subject: [PATCH 09/21] Adjust cid in tests after changing doc's storage --- .../events/simple/with_update_test.go | 4 ++-- .../simple/create/with_version_test.go | 2 +- .../integration/query/commits/simple_test.go | 8 +++---- .../query/commits/with_depth_test.go | 12 +++++----- .../query/commits/with_dockey_count_test.go | 2 +- .../query/commits/with_dockey_field_test.go | 2 +- .../with_dockey_order_limit_offset_test.go | 2 +- .../query/commits/with_dockey_order_test.go | 24 +++++++++---------- .../query/commits/with_dockey_prop_test.go | 2 +- .../query/commits/with_dockey_test.go | 14 +++++------ .../commits/with_dockey_typename_test.go | 2 +- .../query/commits/with_field_test.go | 4 ++-- .../query/commits/with_group_test.go | 6 ++--- .../latest_commits/with_dockey_field_test.go | 2 +- .../query/latest_commits/with_dockey_test.go | 4 ++-- 15 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tests/integration/events/simple/with_update_test.go b/tests/integration/events/simple/with_update_test.go index 63fbdbdaad..d1659cec49 100644 --- a/tests/integration/events/simple/with_update_test.go +++ b/tests/integration/events/simple/with_update_test.go @@ -64,14 +64,14 @@ func TestEventsSimpleWithUpdate(t *testing.T) { ExpectedUpdates: []testUtils.ExpectedUpdate{ { DocKey: immutable.Some(docKey1), - Cid: immutable.Some("bafybeifnt627zz5tq5jov57v3ixfigafaarbgucfizk35npgyty4vu3o5e"), + Cid: immutable.Some("bafybeickwwj3ycxexdnslgftwnoozdeezk2puorpmulk2csznmd7o4xgmi"), }, { DocKey: immutable.Some(docKey2), }, { DocKey: immutable.Some(docKey1), - Cid: immutable.Some("bafybeicxlxy6g7tofouasfr4haredha5ubhr44uc364dfui2ccul2tcjbm"), + Cid: immutable.Some("bafybeibtiwjbb6ftknifwh3vm5xykfq4pi5lpxekqs6cs6o3o2dgtnjjxa"), }, }, } diff --git a/tests/integration/mutation/simple/create/with_version_test.go b/tests/integration/mutation/simple/create/with_version_test.go index b7740a22e5..36cc20e1fc 100644 --- a/tests/integration/mutation/simple/create/with_version_test.go +++ b/tests/integration/mutation/simple/create/with_version_test.go @@ -31,7 +31,7 @@ func TestMutationCreateSimpleReturnVersionCID(t *testing.T) { { "_version": []map[string]any{ { - "cid": "bafybeifshtxii3suhkjbynfmxxmonzjju5rhy4fllvrgc5tvodxh6ap5im", + "cid": "bafybeictevbrytwpeyvd4dsx57jl7saop7i3oppq4hcauz3a66ll2chwty", }, }, }, diff --git a/tests/integration/query/commits/simple_test.go b/tests/integration/query/commits/simple_test.go index dc6aea68da..1f4de0f697 100644 --- a/tests/integration/query/commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -40,7 +40,7 @@ func TestQueryCommits(t *testing.T) { "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, } @@ -76,7 +76,7 @@ func TestQueryCommitsMultipleDocs(t *testing.T) { "cid": "bafybeifycjhxcrn3kspu3tajpk2qvlto5mmaxx22bb2tk5ly6dbhc43p5u", }, { - "cid": "bafybeid5s677eie3naujdwf6s6ffs2auoamlro2zzt6uk5eldumcvhxkxa", + "cid": "bafybeidzzv4pnmx4xzfopyznmud6swrh2labbvsczpnqjvshqqkrgrc2uu", }, { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", @@ -85,7 +85,7 @@ func TestQueryCommitsMultipleDocs(t *testing.T) { "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, } @@ -120,7 +120,7 @@ func TestQueryCommitsWithSchemaVersionIdField(t *testing.T) { "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, }, diff --git a/tests/integration/query/commits/with_depth_test.go b/tests/integration/query/commits/with_depth_test.go index ab8292f5c3..00b4380e60 100644 --- a/tests/integration/query/commits/with_depth_test.go +++ b/tests/integration/query/commits/with_depth_test.go @@ -40,7 +40,7 @@ func TestQueryCommitsWithDepth1(t *testing.T) { "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, } @@ -86,7 +86,7 @@ func TestQueryCommitsWithDepth1WithUpdate(t *testing.T) { }, { // "Age" field head - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, }, @@ -142,12 +142,12 @@ func TestQueryCommitsWithDepth2WithUpdate(t *testing.T) { }, { // "Age" field head - "cid": "bafybeifodfb4kakigrsaobafpz2xogmylr33qphdjjkumseu7dkzlpbvem", + "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", "height": int64(3), }, { // "Age" field head -1 - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, }, @@ -184,7 +184,7 @@ func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, { "cid": "bafybeie4ciqu6dwoovbrzjuzlpy6ene3ahhiqz7ocrcxeb2h4zkifhqdr4", @@ -193,7 +193,7 @@ func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { "cid": "bafybeifj66t5p5df7ksiod6asvyyk6zduejzd7pncbpnaospn5mmjdr5bq", }, { - "cid": "bafybeifcai3fhjagpl533axa2yju2ayd53gwdipcuh4ywzqazk7k4xo5zi", + "cid": "bafybeielpy36cijvx3ffpq3oxd4knmui7h5hrruvcb5it4homf5krylpsi", }, }, } diff --git a/tests/integration/query/commits/with_dockey_count_test.go b/tests/integration/query/commits/with_dockey_count_test.go index ff4375939c..8c5f36245c 100644 --- a/tests/integration/query/commits/with_dockey_count_test.go +++ b/tests/integration/query/commits/with_dockey_count_test.go @@ -43,7 +43,7 @@ func TestQueryCommitsWithDockeyAndLinkCount(t *testing.T) { "_count": 0, }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "_count": 2, }, }, diff --git a/tests/integration/query/commits/with_dockey_field_test.go b/tests/integration/query/commits/with_dockey_field_test.go index f29e504fcd..f7489014bd 100644 --- a/tests/integration/query/commits/with_dockey_field_test.go +++ b/tests/integration/query/commits/with_dockey_field_test.go @@ -132,7 +132,7 @@ func TestQueryCommitsWithDockeyAndCompositeFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, } diff --git a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go index 7945aff52b..025b2e8077 100644 --- a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go @@ -50,7 +50,7 @@ func TestQueryCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, { diff --git a/tests/integration/query/commits/with_dockey_order_test.go b/tests/integration/query/commits/with_dockey_order_test.go index 282cff17c8..cc2eb9a5e1 100644 --- a/tests/integration/query/commits/with_dockey_order_test.go +++ b/tests/integration/query/commits/with_dockey_order_test.go @@ -48,7 +48,7 @@ func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { "height": int64(2), }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, { @@ -60,7 +60,7 @@ func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { "height": int64(1), }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "height": int64(1), }, }, @@ -105,7 +105,7 @@ func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { "height": int64(1), }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "height": int64(1), }, { @@ -113,7 +113,7 @@ func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { "height": int64(2), }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, }, @@ -154,11 +154,11 @@ func TestQueryCommitsWithDockeyAndOrderCidDesc(t *testing.T) { "height": int64(2), }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "height": int64(1), }, { @@ -211,11 +211,11 @@ func TestQueryCommitsWithDockeyAndOrderCidAsc(t *testing.T) { "height": int64(1), }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "height": int64(1), }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, { @@ -270,7 +270,7 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { "height": int64(1), }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "height": int64(1), }, { @@ -278,7 +278,7 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { "height": int64(2), }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, { @@ -286,7 +286,7 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { "height": int64(3), }, { - "cid": "bafybeifodfb4kakigrsaobafpz2xogmylr33qphdjjkumseu7dkzlpbvem", + "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", "height": int64(3), }, { @@ -294,7 +294,7 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { "height": int64(4), }, { - "cid": "bafybeid6gm7723nfhmxqprclrnynxyyaf5mddxq2ggjqy4h344tykzpig4", + "cid": "bafybeic4rhgl4pvsh3z5rtr5tzm3zzakyivju6mqemq5v4xqxh7otgrjri", "height": int64(4), }, }, diff --git a/tests/integration/query/commits/with_dockey_prop_test.go b/tests/integration/query/commits/with_dockey_prop_test.go index b72aff2861..c59431cee8 100644 --- a/tests/integration/query/commits/with_dockey_prop_test.go +++ b/tests/integration/query/commits/with_dockey_prop_test.go @@ -47,7 +47,7 @@ func TestQueryCommitsWithDockeyProperty(t *testing.T) { "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", }, }, diff --git a/tests/integration/query/commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go index e7ffdffb18..3bb5c12935 100644 --- a/tests/integration/query/commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -66,7 +66,7 @@ func TestQueryCommitsWithDockey(t *testing.T) { "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, }, @@ -110,7 +110,7 @@ func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { "links": []map[string]any{}, }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "links": []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", @@ -172,11 +172,11 @@ func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { "height": int64(1), }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "height": int64(2), }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "height": int64(1), }, }, @@ -240,20 +240,20 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { "links": []map[string]any{}, }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", "links": []map[string]any{ { "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", "name": "Age", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "name": "_head", }, }, }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "links": []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", diff --git a/tests/integration/query/commits/with_dockey_typename_test.go b/tests/integration/query/commits/with_dockey_typename_test.go index 96c1df2c03..f79bdb4a85 100644 --- a/tests/integration/query/commits/with_dockey_typename_test.go +++ b/tests/integration/query/commits/with_dockey_typename_test.go @@ -43,7 +43,7 @@ func TestQueryCommitsWithDockeyWithTypeName(t *testing.T) { "__typename": "Commit", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "__typename": "Commit", }, }, diff --git a/tests/integration/query/commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go index 953b1d1acf..9cf0a9dbe8 100644 --- a/tests/integration/query/commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -88,7 +88,7 @@ func TestQueryCommitsWithCompositeFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, } @@ -117,7 +117,7 @@ func TestQueryCommitsWithCompositeFieldIdWithReturnedSchemaVersionId(t *testing. }, Results: []map[string]any{ { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, }, diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index 2dfadd7d5d..12b0fabf7b 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -90,7 +90,7 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", }, { - "cid": "bafybeigeigzhjtf27o3wkdyq3exmnqhr3npt5psdq3pywpwxxdepiebpdi", + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", }, }, }, @@ -104,7 +104,7 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", }, }, }, @@ -152,7 +152,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }, }, { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "_group": []map[string]any{ { "height": int64(1), diff --git a/tests/integration/query/latest_commits/with_dockey_field_test.go b/tests/integration/query/latest_commits/with_dockey_field_test.go index 16875d06f9..7b2f2fc92b 100644 --- a/tests/integration/query/latest_commits/with_dockey_field_test.go +++ b/tests/integration/query/latest_commits/with_dockey_field_test.go @@ -101,7 +101,7 @@ func TestQueryLatestCommitsWithDocKeyAndCompositeFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "links": []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", diff --git a/tests/integration/query/latest_commits/with_dockey_test.go b/tests/integration/query/latest_commits/with_dockey_test.go index d82ce7ff1c..68bdfea029 100644 --- a/tests/integration/query/latest_commits/with_dockey_test.go +++ b/tests/integration/query/latest_commits/with_dockey_test.go @@ -38,7 +38,7 @@ func TestQueryLatestCommitsWithDocKey(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "links": []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", @@ -75,7 +75,7 @@ func TestQueryLatestCommitsWithDocKeyWithSchemaVersionIdField(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidr2z5ahvvss5j664gxyna5wjil5ndfjbmllnsewkjf6cnsvsmmqu", + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, }, From 3a2dd126a47997fbc03c696b282c127f77111848 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Tue, 21 Mar 2023 17:02:15 +0100 Subject: [PATCH 10/21] Add test for dockey field for _version doc --- .../query/simple/with_version_test.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/integration/query/simple/with_version_test.go b/tests/integration/query/simple/with_version_test.go index 95c8313b43..c7c913038b 100644 --- a/tests/integration/query/simple/with_version_test.go +++ b/tests/integration/query/simple/with_version_test.go @@ -100,6 +100,40 @@ func TestQuerySimpleWithEmbeddedLatestCommitWithSchemaVersionId(t *testing.T) { executeTestCase(t, test) } +func TestQuerySimpleWithEmbeddedLatestCommitWithDockey(t *testing.T) { + test := testUtils.RequestTestCase{ + Description: "Embedded commits query within object query with schema version id", + Request: `query { + users { + Name + _version { + dockey + } + } + }`, + Docs: map[int][]string{ + 0: { + `{ + "Name": "John", + "Age": 21 + }`, + }, + }, + Results: []map[string]any{ + { + "Name": "John", + "_version": []map[string]any{ + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + }, + }, + }, + } + + executeTestCase(t, test) +} + func TestQuerySimpleWithMultipleAliasedEmbeddedLatestCommit(t *testing.T) { test := testUtils.RequestTestCase{ Description: "Embedded, aliased, latest commits query within object query", From a7f53a135015549271c153aba44d28dc8b3e4586 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Wed, 22 Mar 2023 08:59:08 +0100 Subject: [PATCH 11/21] Add dockey field to groupby and order for commits --- request/graphql/schema/types/commits.go | 4 + .../query/commits/with_group_test.go | 80 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/request/graphql/schema/types/commits.go b/request/graphql/schema/types/commits.go index aba5c59b89..995bc933ef 100644 --- a/request/graphql/schema/types/commits.go +++ b/request/graphql/schema/types/commits.go @@ -107,6 +107,9 @@ var ( "cid": &gql.InputObjectFieldConfig{ Type: OrderingEnum, }, + "dockey": &gql.InputObjectFieldConfig{ + Type: OrderingEnum, + }, }, }, ) @@ -117,6 +120,7 @@ var ( Values: gql.EnumValueConfigMap{ "height": &gql.EnumValueConfig{Value: "height"}, "cid": &gql.EnumValueConfig{Value: "cid"}, + "dockey": &gql.EnumValueConfig{Value: "dockey"}, }, }, ) diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index 12b0fabf7b..6f641616b4 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -164,3 +164,83 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { executeTestCase(t, test) } + +func TestQueryCommitsWithGroupByDocKey(t *testing.T) { + test := testUtils.RequestTestCase{ + Description: "Simple all commits query, group by dockey", + Request: `query { + commits(groupBy: [dockey]) { + dockey + } + }`, + Docs: map[int][]string{ + 0: { + `{ + "Name": "John", + "Age": 21 + }`, + `{ + "Name": "Fred", + "Age": 25 + }`, + }, + }, + Updates: map[int]map[int][]string{ + 0: { + 0: { + `{ + "Age": 22 + }`, + }, + 1: { + `{ + "Age": 26 + }`, + }, + }, + }, + Results: []map[string]any{ + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + { + "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", + }, + }, + } + + executeTestCase(t, test) +} + +func TestQueryCommitsWithOrderedByDocKey(t *testing.T) { + test := testUtils.RequestTestCase{ + Description: "Simple all commits query, grouped and ordered by height", + Request: `query { + commits(groupBy: [dockey], order: {dockey: DESC}) { + dockey + } + }`, + Docs: map[int][]string{ + 0: { + `{ + "Name": "John", + "Age": 21 + }`, + `{ + "Name": "Fred", + "Age": 25 + }`, + }, + }, + Results: []map[string]any{ + { + "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", + }, + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + }, + } + + executeTestCase(t, test) +} From adfc32dd0856c3d6d32605a1d02d06b6cdee2041 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Wed, 22 Mar 2023 10:55:00 +0100 Subject: [PATCH 12/21] Switch to new testing framework --- .../integration/query/commits/simple_test.go | 173 ++++--- tests/integration/query/commits/utils.go | 20 +- .../query/commits/with_cid_test.go | 176 ++++--- .../query/commits/with_depth_test.go | 283 ++++++----- .../query/commits/with_dockey_cid_test.go | 126 +++-- .../query/commits/with_dockey_count_test.go | 54 +-- .../query/commits/with_dockey_field_test.go | 146 +++--- .../commits/with_dockey_limit_offset_test.go | 62 +-- .../query/commits/with_dockey_limit_test.go | 56 +-- .../with_dockey_order_limit_offset_test.go | 68 +-- .../query/commits/with_dockey_order_test.go | 452 +++++++++--------- .../query/commits/with_dockey_prop_test.go | 16 +- .../query/commits/with_dockey_test.go | 116 ++--- .../commits/with_dockey_typename_test.go | 54 +-- .../query/commits/with_field_test.go | 132 +++-- .../query/commits/with_group_test.go | 310 ++++++------ 16 files changed, 1078 insertions(+), 1166 deletions(-) diff --git a/tests/integration/query/commits/simple_test.go b/tests/integration/query/commits/simple_test.go index 1f4de0f697..45cf5b0585 100644 --- a/tests/integration/query/commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -17,114 +17,111 @@ import ( ) func TestQueryCommits(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query", - Request: `query { - commits { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsMultipleDocs(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query, multiple docs", - Request: `query { - commits { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - `{ - "Name": "Shahzad", - "Age": 28 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeih23ppd7pcp2rbuntybstbt6hwhg4qqeoxl4hfelehmpxmljvtysm", - }, - { - "cid": "bafybeifycjhxcrn3kspu3tajpk2qvlto5mmaxx22bb2tk5ly6dbhc43p5u", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Shahzad", + "Age": 28 + }`, }, - { - "cid": "bafybeidzzv4pnmx4xzfopyznmud6swrh2labbvsczpnqjvshqqkrgrc2uu", - }, - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + testUtils.Request{ + Request: `query { + commits { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeih23ppd7pcp2rbuntybstbt6hwhg4qqeoxl4hfelehmpxmljvtysm", + }, + { + "cid": "bafybeifycjhxcrn3kspu3tajpk2qvlto5mmaxx22bb2tk5ly6dbhc43p5u", + }, + { + "cid": "bafybeidzzv4pnmx4xzfopyznmud6swrh2labbvsczpnqjvshqqkrgrc2uu", + }, + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithSchemaVersionIdField(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple commits query yielding schemaVersionId", - Request: `query { - commits { - cid - schemaVersionId - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits { + cid + schemaVersionId + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/utils.go b/tests/integration/query/commits/utils.go index 4a7e291a54..055bcec5e5 100644 --- a/tests/integration/query/commits/utils.go +++ b/tests/integration/query/commits/utils.go @@ -11,12 +11,10 @@ package commits import ( - "testing" - testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -var userCollectionGQLSchema = (` +const userCollectionGQLSchema = (` type users { Name: String Age: Int @@ -24,6 +22,18 @@ var userCollectionGQLSchema = (` } `) -func executeTestCase(t *testing.T, test testUtils.RequestTestCase) { - testUtils.ExecuteRequestTestCase(t, userCollectionGQLSchema, []string{"users"}, test) +func updateUserCollectionSchema() testUtils.SchemaUpdate { + return testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + } +} + +func createJohnDoc() testUtils.CreateDoc { + return testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + } } diff --git a/tests/integration/query/commits/with_cid_test.go b/tests/integration/query/commits/with_cid_test.go index 5a029efff9..9ca9802fa6 100644 --- a/tests/integration/query/commits/with_cid_test.go +++ b/tests/integration/query/commits/with_cid_test.go @@ -17,139 +17,127 @@ import ( ) func TestQueryCommitsWithCid(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with cid", - Request: `query { - commits( - cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + testUtils.Request{ + Request: `query { + commits( + cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" + ) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithCidForFieldCommit(t *testing.T) { // cid is for a field commit, see TestQueryCommitsWithDockeyAndFieldId - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with cid", - Request: `query { - commits( - cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits( + cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" + ) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithInvalidCid(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "query for a single block by invalid CID", - Request: `query { - commits(cid: "fhbnjfahfhfhanfhga") { - cid - height - delta - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(cid: "fhbnjfahfhfhanfhga") { + cid + height + delta + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithInvalidShortCid(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "query for a single block by invalid, short CID", - Request: `query { - commits(cid: "bafybeidfhbnjfahfhfhanfhga") { - cid - height - delta - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(cid: "bafybeidfhbnjfahfhfhanfhga") { + cid + height + delta + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithUnknownCid(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "query for a single block by unknown CID", - Request: `query { - commits(cid: "bafybeid57gpbwi4i6bg7g35hhhhhhhhhhhhhhhhhhhhhhhdoesnotexist") { - cid - height - delta - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(cid: "bafybeid57gpbwi4i6bg7g35hhhhhhhhhhhhhhhhhhhhhhhdoesnotexist") { + cid + height + delta + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_depth_test.go b/tests/integration/query/commits/with_depth_test.go index 00b4380e60..e11241a3f6 100644 --- a/tests/integration/query/commits/with_depth_test.go +++ b/tests/integration/query/commits/with_depth_test.go @@ -17,186 +17,181 @@ import ( ) func TestQueryCommitsWithDepth1(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with depth 1", - Request: `query { - commits(depth: 1) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(depth: 1) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDepth1WithUpdate(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with depth 1, and doc updates", - Request: `query { - commits(depth: 1) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), - }, - { - // "Name" field head (unchanged from create) - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), - }, - { - // "Age" field head - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), + testUtils.Request{ + Request: `query { + commits(depth: 1) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + // "Name" field head (unchanged from create) + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + // "Age" field head + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDepth2WithUpdate(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with depth 2, and doc updates", - Request: `query { - commits(depth: 2) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 23 }`, - }, - }, - }, - Results: []map[string]any{ - { - // Composite head - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", - "height": int64(3), - }, - { - // Composite head -1 - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), - }, - { - // "Name" field head (unchanged from create) - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), }, - { - // "Age" field head - "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", - "height": int64(3), - }, - { - // "Age" field head -1 - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), + testUtils.Request{ + Request: `query { + commits(depth: 2) { + cid + height + } + }`, + Results: []map[string]any{ + { + // Composite head + "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "height": int64(3), + }, + { + // Composite head -1 + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + // "Name" field head (unchanged from create) + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + // "Age" field head + "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", + "height": int64(3), + }, + { + // "Age" field head -1 + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with depth 1", - Request: `query { - commits(depth: 1) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - `{ - "Name": "Fred", - "Age": 25 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - }, - { - "cid": "bafybeie4ciqu6dwoovbrzjuzlpy6ene3ahhiqz7ocrcxeb2h4zkifhqdr4", - }, - { - "cid": "bafybeifj66t5p5df7ksiod6asvyyk6zduejzd7pncbpnaospn5mmjdr5bq", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Fred", + "Age": 25 + }`, }, - { - "cid": "bafybeielpy36cijvx3ffpq3oxd4knmui7h5hrruvcb5it4homf5krylpsi", + testUtils.Request{ + Request: `query { + commits(depth: 1) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + { + "cid": "bafybeie4ciqu6dwoovbrzjuzlpy6ene3ahhiqz7ocrcxeb2h4zkifhqdr4", + }, + { + "cid": "bafybeifj66t5p5df7ksiod6asvyyk6zduejzd7pncbpnaospn5mmjdr5bq", + }, + { + "cid": "bafybeielpy36cijvx3ffpq3oxd4knmui7h5hrruvcb5it4homf5krylpsi", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_cid_test.go b/tests/integration/query/commits/with_dockey_cid_test.go index 34dd3ec00d..1f5bb491ce 100644 --- a/tests/integration/query/commits/with_dockey_cid_test.go +++ b/tests/integration/query/commits/with_dockey_cid_test.go @@ -17,98 +17,88 @@ import ( ) func TestQueryCommitsWithDockeyAndCidForDifferentDoc(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and cid", - Request: `query { - commits( - dockey: "bae-not-this-doc", - cid: "bafybeica4js2abwqjjrz7dcialbortbz32uxp7ufxu7yljbwvmhjqqxzny" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: ` { + commits( + dockey: "bae-not-this-doc", + cid: "bafybeica4js2abwqjjrz7dcialbortbz32uxp7ufxu7yljbwvmhjqqxzny" + ) { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndCidForDifferentDocWithUpdate(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and cid", - Request: `query { - commits( - dockey: "bae-not-this-doc", - cid: "bafybeica4js2abwqjjrz7dcialbortbz32uxp7ufxu7yljbwvmhjqqxzny" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, + }, + testUtils.Request{ + Request: ` { + commits( + dockey: "bae-not-this-doc", + cid: "bafybeica4js2abwqjjrz7dcialbortbz32uxp7ufxu7yljbwvmhjqqxzny" + ) { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndCid(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and cid", - Request: `query { - commits( - dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", - cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + testUtils.Request{ + Request: ` { + commits( + dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" + ) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_count_test.go b/tests/integration/query/commits/with_dockey_count_test.go index 8c5f36245c..52548e07c3 100644 --- a/tests/integration/query/commits/with_dockey_count_test.go +++ b/tests/integration/query/commits/with_dockey_count_test.go @@ -17,37 +17,35 @@ import ( ) func TestQueryCommitsWithDockeyAndLinkCount(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple latest commits query with dockey and link count", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - _count(field: links) - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "_count": 0, - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "_count": 0, - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "_count": 2, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + cid + _count(field: links) + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "_count": 0, + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "_count": 0, + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "_count": 2, + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_field_test.go b/tests/integration/query/commits/with_dockey_field_test.go index f7489014bd..5024195a35 100644 --- a/tests/integration/query/commits/with_dockey_field_test.go +++ b/tests/integration/query/commits/with_dockey_field_test.go @@ -17,125 +17,115 @@ import ( ) func TestQueryCommitsWithDockeyAndUnknownField(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and unknown field", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "not a field") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "not a field") { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndUnknownFieldId(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and unknown field id", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "999999") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "999999") { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (should return all commits for dockey-field). func TestQueryCommitsWithDockeyAndField(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and field", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "Age") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "Age") { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). func TestQueryCommitsWithDockeyAndFieldId(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and field id", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "1") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "1") { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). func TestQueryCommitsWithDockeyAndCompositeFieldId(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and field id", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "C") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "C") { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_limit_offset_test.go b/tests/integration/query/commits/with_dockey_limit_offset_test.go index 009cd369a4..8ec5265820 100644 --- a/tests/integration/query/commits/with_dockey_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_limit_offset_test.go @@ -17,45 +17,49 @@ import ( ) func TestQueryCommitsWithDockeyAndLimitAndOffset(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, limit and offset", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2, offset: 1) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 23 }`, - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 24 }`, - }, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", - }, - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + testUtils.Request{ + Request: ` { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2, offset: 1) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + }, + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_limit_test.go b/tests/integration/query/commits/with_dockey_limit_test.go index 9bc1ad2993..3e6fe78fe4 100644 --- a/tests/integration/query/commits/with_dockey_limit_test.go +++ b/tests/integration/query/commits/with_dockey_limit_test.go @@ -17,42 +17,42 @@ import ( ) func TestQueryCommitsWithDockeyAndLimit(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and limit", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 23 }`, - }, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", - }, - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + testUtils.Request{ + Request: ` { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2) { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + }, + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go index 025b2e8077..396392fa44 100644 --- a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go @@ -17,48 +17,52 @@ import ( ) func TestQueryCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, order, limit and offset", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}, limit: 2, offset: 4) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 23 }`, - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 24 }`, - }, }, - }, - Results: []map[string]any{ - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), - }, - { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", - "height": int64(3), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}, limit: 2, offset: 4) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + { + "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "height": int64(3), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_order_test.go b/tests/integration/query/commits/with_dockey_order_test.go index cc2eb9a5e1..6beea249ae 100644 --- a/tests/integration/query/commits/with_dockey_order_test.go +++ b/tests/integration/query/commits/with_dockey_order_test.go @@ -17,288 +17,276 @@ import ( ) func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, order height desc", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: DESC}) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), - }, - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), - }, - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "height": int64(1), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: DESC}) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "height": int64(1), + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "height": int64(1), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, order height asc", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "height": int64(1), - }, - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), }, - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "height": int64(1), + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "height": int64(1), + }, + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndOrderCidDesc(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, order cid desc", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: DESC}) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), - }, - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "height": int64(1), - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), }, - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: DESC}) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "height": int64(1), + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "height": int64(1), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndOrderCidAsc(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, order cid asc", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: ASC}) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "height": int64(1), - }, - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), - }, - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: ASC}) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "height": int64(1), + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "height": int64(1), + }, + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey, multiple updates with order cid asc", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { - cid - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ - "Age": 22 - }`, - `{ - "Age": 23 - }`, - `{ - "Age": 24 - }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "height": int64(1), - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "height": int64(1), - }, - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), - }, - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - "height": int64(2), - }, - { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", - "height": int64(3), + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, }, - { - "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", - "height": int64(3), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 23 + }`, }, - { - "cid": "bafybeic4slf53yiert4jrdeyvqij3rnat2iikgbn7fdn6n6zowu66dylbi", - "height": int64(4), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 24 + }`, }, - { - "cid": "bafybeic4rhgl4pvsh3z5rtr5tzm3zzakyivju6mqemq5v4xqxh7otgrjri", - "height": int64(4), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { + cid + height + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "height": int64(1), + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(1), + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "height": int64(1), + }, + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "height": int64(2), + }, + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "height": int64(2), + }, + { + "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "height": int64(3), + }, + { + "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", + "height": int64(3), + }, + { + "cid": "bafybeic4slf53yiert4jrdeyvqij3rnat2iikgbn7fdn6n6zowu66dylbi", + "height": int64(4), + }, + { + "cid": "bafybeic4rhgl4pvsh3z5rtr5tzm3zzakyivju6mqemq5v4xqxh7otgrjri", + "height": int64(4), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_dockey_prop_test.go b/tests/integration/query/commits/with_dockey_prop_test.go index c59431cee8..101b9e9b6e 100644 --- a/tests/integration/query/commits/with_dockey_prop_test.go +++ b/tests/integration/query/commits/with_dockey_prop_test.go @@ -26,17 +26,17 @@ func TestQueryCommitsWithDockeyProperty(t *testing.T) { testUtils.CreateDoc{ CollectionID: 0, Doc: `{ - "Name": "John", - "Age": 21 - }`, + "Name": "John", + "Age": 21 + }`, }, testUtils.Request{ Request: `query { - commits { - cid - dockey - } - }`, + commits { + cid + dockey + } + }`, Results: []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", diff --git a/tests/integration/query/commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go index 3bb5c12935..0cf949e316 100644 --- a/tests/integration/query/commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -17,47 +17,37 @@ import ( ) func TestQueryCommitsWithUnknownDockey(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with unknown dockey", - Request: `query { - commits(dockey: "unknown dockey") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "unknown dockey") { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithDockey(t *testing.T) { test := testUtils.TestCase{ Description: "Simple all commits query with dockey", Actions: []any{ - testUtils.SchemaUpdate{ - Schema: userCollectionGQLSchema, - }, - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "John", - "Age": 21 - }`, - }, + updateUserCollectionSchema(), + createJohnDoc(), testUtils.Request{ Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - } - }`, + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + cid + } + }`, Results: []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", @@ -80,26 +70,18 @@ func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { test := testUtils.TestCase{ Description: "Simple all commits query with dockey, with links", Actions: []any{ - testUtils.SchemaUpdate{ - Schema: userCollectionGQLSchema, - }, - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "John", - "Age": 21 - }`, - }, + updateUserCollectionSchema(), + createJohnDoc(), testUtils.Request{ Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - links { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid - name + links { + cid + name + } } - } - }`, + }`, Results: []map[string]any{ { "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", @@ -134,16 +116,8 @@ func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { test := testUtils.TestCase{ Description: "Simple all commits query with dockey, multiple results", Actions: []any{ - testUtils.SchemaUpdate{ - Schema: userCollectionGQLSchema, - }, - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "John", - "Age": 21 - }`, - }, + updateUserCollectionSchema(), + createJohnDoc(), testUtils.UpdateDoc{ CollectionID: 0, DocID: 0, @@ -153,11 +127,11 @@ func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { }, testUtils.Request{ Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - height - } - }`, + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + cid + height + } + }`, Results: []map[string]any{ { "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", @@ -194,16 +168,8 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { test := testUtils.TestCase{ Description: "Simple all commits query with dockey, multiple results and links", Actions: []any{ - testUtils.SchemaUpdate{ - Schema: userCollectionGQLSchema, - }, - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "John", - "Age": 21 - }`, - }, + updateUserCollectionSchema(), + createJohnDoc(), testUtils.UpdateDoc{ CollectionID: 0, DocID: 0, @@ -213,14 +179,14 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { }, testUtils.Request{ Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - links { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid - name + links { + cid + name + } } - } - }`, + }`, Results: []map[string]any{ { "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", diff --git a/tests/integration/query/commits/with_dockey_typename_test.go b/tests/integration/query/commits/with_dockey_typename_test.go index f79bdb4a85..83e1d3d04e 100644 --- a/tests/integration/query/commits/with_dockey_typename_test.go +++ b/tests/integration/query/commits/with_dockey_typename_test.go @@ -17,37 +17,35 @@ import ( ) func TestQueryCommitsWithDockeyWithTypeName(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and typename", - Request: `query { - commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { - cid - __typename - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "__typename": "Commit", - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "__typename": "Commit", - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "__typename": "Commit", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + cid + __typename + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "__typename": "Commit", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "__typename": "Commit", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "__typename": "Commit", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go index 9cf0a9dbe8..0a95f3930a 100644 --- a/tests/integration/query/commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -19,109 +19,101 @@ import ( // This test is for documentation reasons only. This is not // desired behaviour (should return all commits for dockey-field). func TestQueryCommitsWithField(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with field", - Request: `query { - commits (field: "Age") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits (field: "Age") { + cid + } + }`, + Results: []map[string]any{}, }, }, - Results: []map[string]any{}, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). func TestQueryCommitsWithFieldId(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with field id", - Request: `query { - commits (field: "1") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits (field: "1") { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). func TestQueryCommitsWithCompositeFieldId(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and field id", - Request: `query { - commits(field: "C") { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(field: "C") { + cid + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). func TestQueryCommitsWithCompositeFieldIdWithReturnedSchemaVersionId(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query with dockey and field id", - Request: `query { - commits(field: "C") { - cid - schemaVersionId - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: `query { + commits(field: "C") { + cid + schemaVersionId + } + }`, + Results: []map[string]any{ + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index 6f641616b4..5457e8daec 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -17,230 +17,222 @@ import ( ) func TestQueryCommitsWithGroupBy(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query, group by height", - Request: `query { - commits(groupBy: [height]) { - height - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, }, - }, - Results: []map[string]any{ - { - "height": int64(2), - }, - { - "height": int64(1), + testUtils.Request{ + Request: ` { + commits(groupBy: [height]) { + height + } + }`, + Results: []map[string]any{ + { + "height": int64(2), + }, + { + "height": int64(1), + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query, group by height", - Request: `query { - commits(groupBy: [height]) { - height - _group { - cid - } - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - }, - }, - Results: []map[string]any{ - { - "height": int64(2), - "_group": []map[string]any{ - { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - }, - { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", - }, - }, }, - { - "height": int64(1), - "_group": []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - }, + testUtils.Request{ + Request: ` { + commits(groupBy: [height]) { + height + _group { + cid + } + } + }`, + Results: []map[string]any{ { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "height": int64(2), + "_group": []map[string]any{ + { + "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + }, + { + "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + }, + }, }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "height": int64(1), + "_group": []map[string]any{ + { + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + }, + { + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + }, + { + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + }, + }, }, }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } // This is an odd test, but we need to make sure it works func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query, group by cid", - Request: `query { - commits(groupBy: [cid]) { - cid - _group { - height + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.Request{ + Request: ` { + commits(groupBy: [cid]) { + cid + _group { + height + } } - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "_group": []map[string]any{ + }`, + Results: []map[string]any{ { - "height": int64(1), + "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "_group": []map[string]any{ + { + "height": int64(1), + }, + }, }, - }, - }, - { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", - "_group": []map[string]any{ { - "height": int64(1), + "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "_group": []map[string]any{ + { + "height": int64(1), + }, + }, }, - }, - }, - { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", - "_group": []map[string]any{ { - "height": int64(1), + "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "_group": []map[string]any{ + { + "height": int64(1), + }, + }, }, }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithGroupByDocKey(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query, group by dockey", - Request: `query { - commits(groupBy: [dockey]) { - dockey - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - `{ - "Name": "Fred", - "Age": 25 - }`, + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Fred", + "Age": 25 + }`, }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ "Age": 22 }`, - }, - 1: { - `{ + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 1, + Doc: `{ "Age": 26 }`, - }, - }, - }, - Results: []map[string]any{ - { - "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", }, - { - "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", + testUtils.Request{ + Request: ` { + commits(groupBy: [dockey]) { + dockey + } + }`, + Results: []map[string]any{ + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + { + "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } func TestQueryCommitsWithOrderedByDocKey(t *testing.T) { - test := testUtils.RequestTestCase{ + test := testUtils.TestCase{ Description: "Simple all commits query, grouped and ordered by height", - Request: `query { - commits(groupBy: [dockey], order: {dockey: DESC}) { - dockey - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - `{ + Actions: []any{ + updateUserCollectionSchema(), + createJohnDoc(), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ "Name": "Fred", "Age": 25 }`, }, - }, - Results: []map[string]any{ - { - "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", - }, - { - "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + testUtils.Request{ + Request: ` { + commits(groupBy: [dockey], order: {dockey: DESC}) { + dockey + } + }`, + Results: []map[string]any{ + { + "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", + }, + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + }, }, }, } - executeTestCase(t, test) + testUtils.ExecuteTestCase(t, []string{"users"}, test) } From 55ae0e95c7e079431de272df5316c71a59514348 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Wed, 22 Mar 2023 11:22:00 +0100 Subject: [PATCH 13/21] Extract update action --- .../integration/query/commits/simple_test.go | 14 ++-- tests/integration/query/commits/utils.go | 20 ++++-- .../query/commits/with_cid_test.go | 18 ++--- .../query/commits/with_depth_test.go | 40 +++-------- .../query/commits/with_dockey_cid_test.go | 22 ++----- .../query/commits/with_dockey_count_test.go | 2 +- .../query/commits/with_dockey_field_test.go | 10 +-- .../commits/with_dockey_limit_offset_test.go | 26 ++------ .../query/commits/with_dockey_limit_test.go | 18 +---- .../with_dockey_order_limit_offset_test.go | 26 ++------ .../query/commits/with_dockey_order_test.go | 66 ++++--------------- .../query/commits/with_dockey_prop_test.go | 12 +--- .../query/commits/with_dockey_test.go | 26 ++------ .../commits/with_dockey_typename_test.go | 2 +- .../query/commits/with_field_test.go | 8 +-- .../query/commits/with_group_test.go | 58 ++++------------ 16 files changed, 93 insertions(+), 275 deletions(-) diff --git a/tests/integration/query/commits/simple_test.go b/tests/integration/query/commits/simple_test.go index 45cf5b0585..262e0a85ed 100644 --- a/tests/integration/query/commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -21,7 +21,7 @@ func TestQueryCommits(t *testing.T) { Description: "Simple all commits query", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits { @@ -51,14 +51,8 @@ func TestQueryCommitsMultipleDocs(t *testing.T) { Description: "Simple all commits query, multiple docs", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "Shahzad", - "Age": 28 - }`, - }, + createDoc("John", 21), + createDoc("Shahzad", 28), testUtils.Request{ Request: `query { commits { @@ -97,7 +91,7 @@ func TestQueryCommitsWithSchemaVersionIdField(t *testing.T) { Description: "Simple commits query yielding schemaVersionId", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits { diff --git a/tests/integration/query/commits/utils.go b/tests/integration/query/commits/utils.go index 055bcec5e5..9a570edac0 100644 --- a/tests/integration/query/commits/utils.go +++ b/tests/integration/query/commits/utils.go @@ -11,6 +11,8 @@ package commits import ( + "strconv" + testUtils "github.com/sourcenetwork/defradb/tests/integration" ) @@ -28,12 +30,22 @@ func updateUserCollectionSchema() testUtils.SchemaUpdate { } } -func createJohnDoc() testUtils.CreateDoc { +func createDoc(name string, age int) testUtils.CreateDoc { return testUtils.CreateDoc{ CollectionID: 0, Doc: `{ - "Name": "John", - "Age": 21 - }`, + "Name": "` + name + `", + "Age": ` + strconv.Itoa(age) + ` + }`, + } +} + +func updateAge(DocID int, age int) testUtils.UpdateDoc { + return testUtils.UpdateDoc{ + CollectionID: 0, + DocID: DocID, + Doc: `{ + "Age": ` + strconv.Itoa(age) + ` + }`, } } diff --git a/tests/integration/query/commits/with_cid_test.go b/tests/integration/query/commits/with_cid_test.go index 9ca9802fa6..eba7c1f051 100644 --- a/tests/integration/query/commits/with_cid_test.go +++ b/tests/integration/query/commits/with_cid_test.go @@ -21,14 +21,8 @@ func TestQueryCommitsWithCid(t *testing.T) { Description: "Simple all commits query with cid", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits( @@ -55,7 +49,7 @@ func TestQueryCommitsWithCidForFieldCommit(t *testing.T) { Description: "Simple all commits query with cid", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits( @@ -81,7 +75,7 @@ func TestQueryCommitsWithInvalidCid(t *testing.T) { Description: "query for a single block by invalid CID", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(cid: "fhbnjfahfhfhanfhga") { @@ -103,7 +97,7 @@ func TestQueryCommitsWithInvalidShortCid(t *testing.T) { Description: "query for a single block by invalid, short CID", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(cid: "bafybeidfhbnjfahfhfhanfhga") { @@ -125,7 +119,7 @@ func TestQueryCommitsWithUnknownCid(t *testing.T) { Description: "query for a single block by unknown CID", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(cid: "bafybeid57gpbwi4i6bg7g35hhhhhhhhhhhhhhhhhhhhhhhdoesnotexist") { diff --git a/tests/integration/query/commits/with_depth_test.go b/tests/integration/query/commits/with_depth_test.go index e11241a3f6..f982e9cc7c 100644 --- a/tests/integration/query/commits/with_depth_test.go +++ b/tests/integration/query/commits/with_depth_test.go @@ -21,7 +21,7 @@ func TestQueryCommitsWithDepth1(t *testing.T) { Description: "Simple all commits query with depth 1", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(depth: 1) { @@ -51,14 +51,8 @@ func TestQueryCommitsWithDepth1WithUpdate(t *testing.T) { Description: "Simple all commits query with depth 1, and doc updates", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(depth: 1) { @@ -94,21 +88,9 @@ func TestQueryCommitsWithDepth2WithUpdate(t *testing.T) { Description: "Simple all commits query with depth 2, and doc updates", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 23 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), + updateAge(0, 23), testUtils.Request{ Request: `query { commits(depth: 2) { @@ -155,14 +137,8 @@ func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { Description: "Simple all commits query with depth 1", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "Fred", - "Age": 25 - }`, - }, + createDoc("John", 21), + createDoc("Fred", 25), testUtils.Request{ Request: `query { commits(depth: 1) { diff --git a/tests/integration/query/commits/with_dockey_cid_test.go b/tests/integration/query/commits/with_dockey_cid_test.go index 1f5bb491ce..2b2ffe7d32 100644 --- a/tests/integration/query/commits/with_dockey_cid_test.go +++ b/tests/integration/query/commits/with_dockey_cid_test.go @@ -21,7 +21,7 @@ func TestQueryCommitsWithDockeyAndCidForDifferentDoc(t *testing.T) { Description: "Simple all commits query with dockey and cid", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: ` { commits( @@ -44,14 +44,8 @@ func TestQueryCommitsWithDockeyAndCidForDifferentDocWithUpdate(t *testing.T) { Description: "Simple all commits query with dockey and cid", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: ` { commits( @@ -74,14 +68,8 @@ func TestQueryCommitsWithDockeyAndCid(t *testing.T) { Description: "Simple all commits query with dockey and cid", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: ` { commits( diff --git a/tests/integration/query/commits/with_dockey_count_test.go b/tests/integration/query/commits/with_dockey_count_test.go index 52548e07c3..03d8dddeae 100644 --- a/tests/integration/query/commits/with_dockey_count_test.go +++ b/tests/integration/query/commits/with_dockey_count_test.go @@ -21,7 +21,7 @@ func TestQueryCommitsWithDockeyAndLinkCount(t *testing.T) { Description: "Simple latest commits query with dockey and link count", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { diff --git a/tests/integration/query/commits/with_dockey_field_test.go b/tests/integration/query/commits/with_dockey_field_test.go index 5024195a35..0dedb1b3ef 100644 --- a/tests/integration/query/commits/with_dockey_field_test.go +++ b/tests/integration/query/commits/with_dockey_field_test.go @@ -21,7 +21,7 @@ func TestQueryCommitsWithDockeyAndUnknownField(t *testing.T) { Description: "Simple all commits query with dockey and unknown field", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "not a field") { @@ -41,7 +41,7 @@ func TestQueryCommitsWithDockeyAndUnknownFieldId(t *testing.T) { Description: "Simple all commits query with dockey and unknown field id", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "999999") { @@ -63,7 +63,7 @@ func TestQueryCommitsWithDockeyAndField(t *testing.T) { Description: "Simple all commits query with dockey and field", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "Age") { @@ -85,7 +85,7 @@ func TestQueryCommitsWithDockeyAndFieldId(t *testing.T) { Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "1") { @@ -111,7 +111,7 @@ func TestQueryCommitsWithDockeyAndCompositeFieldId(t *testing.T) { Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "C") { diff --git a/tests/integration/query/commits/with_dockey_limit_offset_test.go b/tests/integration/query/commits/with_dockey_limit_offset_test.go index 8ec5265820..f4ee0fa945 100644 --- a/tests/integration/query/commits/with_dockey_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_limit_offset_test.go @@ -21,28 +21,10 @@ func TestQueryCommitsWithDockeyAndLimitAndOffset(t *testing.T) { Description: "Simple all commits query with dockey, limit and offset", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 23 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 24 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), + updateAge(0, 23), + updateAge(0, 24), testUtils.Request{ Request: ` { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2, offset: 1) { diff --git a/tests/integration/query/commits/with_dockey_limit_test.go b/tests/integration/query/commits/with_dockey_limit_test.go index 3e6fe78fe4..7e273a9ba0 100644 --- a/tests/integration/query/commits/with_dockey_limit_test.go +++ b/tests/integration/query/commits/with_dockey_limit_test.go @@ -21,21 +21,9 @@ func TestQueryCommitsWithDockeyAndLimit(t *testing.T) { Description: "Simple all commits query with dockey and limit", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 23 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), + updateAge(0, 23), testUtils.Request{ Request: ` { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2) { diff --git a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go index 396392fa44..66abb03af3 100644 --- a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go @@ -21,28 +21,10 @@ func TestQueryCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { Description: "Simple all commits query with dockey, order, limit and offset", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 23 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 24 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), + updateAge(0, 23), + updateAge(0, 24), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}, limit: 2, offset: 4) { diff --git a/tests/integration/query/commits/with_dockey_order_test.go b/tests/integration/query/commits/with_dockey_order_test.go index 6beea249ae..2cb95774e3 100644 --- a/tests/integration/query/commits/with_dockey_order_test.go +++ b/tests/integration/query/commits/with_dockey_order_test.go @@ -21,14 +21,8 @@ func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { Description: "Simple all commits query with dockey, order height desc", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: DESC}) { @@ -70,14 +64,8 @@ func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { Description: "Simple all commits query with dockey, order height asc", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { @@ -119,14 +107,8 @@ func TestQueryCommitsWithDockeyAndOrderCidDesc(t *testing.T) { Description: "Simple all commits query with dockey, order cid desc", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: DESC}) { @@ -168,14 +150,8 @@ func TestQueryCommitsWithDockeyAndOrderCidAsc(t *testing.T) { Description: "Simple all commits query with dockey, order cid asc", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: ASC}) { @@ -217,28 +193,10 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { Description: "Simple all commits query with dockey, multiple updates with order cid asc", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 23 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 24 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), + updateAge(0, 23), + updateAge(0, 24), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { diff --git a/tests/integration/query/commits/with_dockey_prop_test.go b/tests/integration/query/commits/with_dockey_prop_test.go index 101b9e9b6e..fd5c15f218 100644 --- a/tests/integration/query/commits/with_dockey_prop_test.go +++ b/tests/integration/query/commits/with_dockey_prop_test.go @@ -20,16 +20,8 @@ func TestQueryCommitsWithDockeyProperty(t *testing.T) { test := testUtils.TestCase{ Description: "Simple commits query with dockey property", Actions: []any{ - testUtils.SchemaUpdate{ - Schema: userCollectionGQLSchema, - }, - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "John", - "Age": 21 - }`, - }, + updateUserCollectionSchema(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits { diff --git a/tests/integration/query/commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go index 0cf949e316..446cfc6a9c 100644 --- a/tests/integration/query/commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -21,7 +21,7 @@ func TestQueryCommitsWithUnknownDockey(t *testing.T) { Description: "Simple all commits query with unknown dockey", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "unknown dockey") { @@ -41,7 +41,7 @@ func TestQueryCommitsWithDockey(t *testing.T) { Description: "Simple all commits query with dockey", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { @@ -71,7 +71,7 @@ func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { Description: "Simple all commits query with dockey, with links", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { @@ -117,14 +117,8 @@ func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { Description: "Simple all commits query with dockey, multiple results", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { @@ -169,14 +163,8 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { Description: "Simple all commits query with dockey, multiple results and links", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { diff --git a/tests/integration/query/commits/with_dockey_typename_test.go b/tests/integration/query/commits/with_dockey_typename_test.go index 83e1d3d04e..612fe318fd 100644 --- a/tests/integration/query/commits/with_dockey_typename_test.go +++ b/tests/integration/query/commits/with_dockey_typename_test.go @@ -21,7 +21,7 @@ func TestQueryCommitsWithDockeyWithTypeName(t *testing.T) { Description: "Simple all commits query with dockey and typename", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { diff --git a/tests/integration/query/commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go index 0a95f3930a..45a49afd6b 100644 --- a/tests/integration/query/commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -23,7 +23,7 @@ func TestQueryCommitsWithField(t *testing.T) { Description: "Simple all commits query with field", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits (field: "Age") { @@ -45,7 +45,7 @@ func TestQueryCommitsWithFieldId(t *testing.T) { Description: "Simple all commits query with field id", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits (field: "1") { @@ -71,7 +71,7 @@ func TestQueryCommitsWithCompositeFieldId(t *testing.T) { Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(field: "C") { @@ -97,7 +97,7 @@ func TestQueryCommitsWithCompositeFieldIdWithReturnedSchemaVersionId(t *testing. Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: `query { commits(field: "C") { diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index 5457e8daec..13d3adeede 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -21,14 +21,8 @@ func TestQueryCommitsWithGroupBy(t *testing.T) { Description: "Simple all commits query, group by height", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: ` { commits(groupBy: [height]) { @@ -55,14 +49,8 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { Description: "Simple all commits query, group by height", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, + createDoc("John", 21), + updateAge(0, 22), testUtils.Request{ Request: ` { commits(groupBy: [height]) { @@ -112,7 +100,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { Description: "Simple all commits query, group by cid", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), + createDoc("John", 21), testUtils.Request{ Request: ` { commits(groupBy: [cid]) { @@ -160,28 +148,10 @@ func TestQueryCommitsWithGroupByDocKey(t *testing.T) { Description: "Simple all commits query, group by dockey", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "Fred", - "Age": 25 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 0, - Doc: `{ - "Age": 22 - }`, - }, - testUtils.UpdateDoc{ - CollectionID: 0, - DocID: 1, - Doc: `{ - "Age": 26 - }`, - }, + createDoc("John", 21), + createDoc("Fred", 25), + updateAge(0, 22), + updateAge(1, 26), testUtils.Request{ Request: ` { commits(groupBy: [dockey]) { @@ -208,14 +178,8 @@ func TestQueryCommitsWithOrderedByDocKey(t *testing.T) { Description: "Simple all commits query, grouped and ordered by height", Actions: []any{ updateUserCollectionSchema(), - createJohnDoc(), - testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "Fred", - "Age": 25 - }`, - }, + createDoc("John", 21), + createDoc("Fred", 25), testUtils.Request{ Request: ` { commits(groupBy: [dockey], order: {dockey: DESC}) { From 1a19021f6022bf588c9fa55fb9dad77b7a4a3c23 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Wed, 22 Mar 2023 17:25:26 +0100 Subject: [PATCH 14/21] Remove todo --- merkle/clock/clock.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merkle/clock/clock.go b/merkle/clock/clock.go index 44c4d4c98a..01ed47e1b9 100644 --- a/merkle/clock/clock.go +++ b/merkle/clock/clock.go @@ -187,7 +187,7 @@ func (mc *MerkleClock) ProcessNode( // we reached a non-head node in the known tree. // This means our root block is a new head log.Debug(ctx, "Adding head") - err := mc.headset.Write(ctx, root, rootPrio) // @todo: optimize: don't write the same value in the loop + err := mc.headset.Write(ctx, root, rootPrio) if err != nil { log.ErrorE( ctx, From e24fce8bc0477eeec7a245f72b6a3525b14e8821 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Thu, 23 Mar 2023 18:00:14 +0100 Subject: [PATCH 15/21] Remove test helper functions --- .../integration/query/commits/simple_test.go | 32 +++++- tests/integration/query/commits/utils.go | 22 ---- .../query/commits/with_cid_test.go | 48 +++++++-- .../query/commits/with_depth_test.go | 64 +++++++++-- .../query/commits/with_dockey_cid_test.go | 40 ++++++- .../query/commits/with_dockey_count_test.go | 8 +- .../query/commits/with_dockey_field_test.go | 40 ++++++- .../commits/with_dockey_group_order_test.go | 57 ++++++++++ .../commits/with_dockey_limit_offset_test.go | 32 +++++- .../query/commits/with_dockey_limit_test.go | 24 ++++- .../with_dockey_order_limit_offset_test.go | 32 +++++- .../query/commits/with_dockey_order_test.go | 96 ++++++++++++++--- .../query/commits/with_dockey_prop_test.go | 12 ++- .../query/commits/with_dockey_test.go | 56 ++++++++-- .../commits/with_dockey_typename_test.go | 8 +- .../query/commits/with_field_test.go | 32 +++++- .../query/commits/with_group_test.go | 100 +++++++++++------- 17 files changed, 575 insertions(+), 128 deletions(-) create mode 100644 tests/integration/query/commits/with_dockey_group_order_test.go diff --git a/tests/integration/query/commits/simple_test.go b/tests/integration/query/commits/simple_test.go index 262e0a85ed..94b60a090b 100644 --- a/tests/integration/query/commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -21,7 +21,13 @@ func TestQueryCommits(t *testing.T) { Description: "Simple all commits query", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits { @@ -51,8 +57,20 @@ func TestQueryCommitsMultipleDocs(t *testing.T) { Description: "Simple all commits query, multiple docs", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - createDoc("Shahzad", 28), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Shahzad", + "Age": 28 + }`, + }, testUtils.Request{ Request: `query { commits { @@ -91,7 +109,13 @@ func TestQueryCommitsWithSchemaVersionIdField(t *testing.T) { Description: "Simple commits query yielding schemaVersionId", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits { diff --git a/tests/integration/query/commits/utils.go b/tests/integration/query/commits/utils.go index 9a570edac0..edac332696 100644 --- a/tests/integration/query/commits/utils.go +++ b/tests/integration/query/commits/utils.go @@ -11,8 +11,6 @@ package commits import ( - "strconv" - testUtils "github.com/sourcenetwork/defradb/tests/integration" ) @@ -29,23 +27,3 @@ func updateUserCollectionSchema() testUtils.SchemaUpdate { Schema: userCollectionGQLSchema, } } - -func createDoc(name string, age int) testUtils.CreateDoc { - return testUtils.CreateDoc{ - CollectionID: 0, - Doc: `{ - "Name": "` + name + `", - "Age": ` + strconv.Itoa(age) + ` - }`, - } -} - -func updateAge(DocID int, age int) testUtils.UpdateDoc { - return testUtils.UpdateDoc{ - CollectionID: 0, - DocID: DocID, - Doc: `{ - "Age": ` + strconv.Itoa(age) + ` - }`, - } -} diff --git a/tests/integration/query/commits/with_cid_test.go b/tests/integration/query/commits/with_cid_test.go index eba7c1f051..1c40237723 100644 --- a/tests/integration/query/commits/with_cid_test.go +++ b/tests/integration/query/commits/with_cid_test.go @@ -21,8 +21,20 @@ func TestQueryCommitsWithCid(t *testing.T) { Description: "Simple all commits query with cid", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits( @@ -49,7 +61,13 @@ func TestQueryCommitsWithCidForFieldCommit(t *testing.T) { Description: "Simple all commits query with cid", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits( @@ -75,7 +93,13 @@ func TestQueryCommitsWithInvalidCid(t *testing.T) { Description: "query for a single block by invalid CID", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(cid: "fhbnjfahfhfhanfhga") { @@ -97,7 +121,13 @@ func TestQueryCommitsWithInvalidShortCid(t *testing.T) { Description: "query for a single block by invalid, short CID", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(cid: "bafybeidfhbnjfahfhfhanfhga") { @@ -119,7 +149,13 @@ func TestQueryCommitsWithUnknownCid(t *testing.T) { Description: "query for a single block by unknown CID", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(cid: "bafybeid57gpbwi4i6bg7g35hhhhhhhhhhhhhhhhhhhhhhhdoesnotexist") { diff --git a/tests/integration/query/commits/with_depth_test.go b/tests/integration/query/commits/with_depth_test.go index f982e9cc7c..016760e9f4 100644 --- a/tests/integration/query/commits/with_depth_test.go +++ b/tests/integration/query/commits/with_depth_test.go @@ -21,7 +21,13 @@ func TestQueryCommitsWithDepth1(t *testing.T) { Description: "Simple all commits query with depth 1", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(depth: 1) { @@ -51,8 +57,20 @@ func TestQueryCommitsWithDepth1WithUpdate(t *testing.T) { Description: "Simple all commits query with depth 1, and doc updates", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(depth: 1) { @@ -88,9 +106,27 @@ func TestQueryCommitsWithDepth2WithUpdate(t *testing.T) { Description: "Simple all commits query with depth 2, and doc updates", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), - updateAge(0, 23), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 23 + }`, + }, testUtils.Request{ Request: `query { commits(depth: 2) { @@ -137,8 +173,20 @@ func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { Description: "Simple all commits query with depth 1", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - createDoc("Fred", 25), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Fred", + "Age": 25 + }`, + }, testUtils.Request{ Request: `query { commits(depth: 1) { diff --git a/tests/integration/query/commits/with_dockey_cid_test.go b/tests/integration/query/commits/with_dockey_cid_test.go index 2b2ffe7d32..e72730048e 100644 --- a/tests/integration/query/commits/with_dockey_cid_test.go +++ b/tests/integration/query/commits/with_dockey_cid_test.go @@ -21,7 +21,13 @@ func TestQueryCommitsWithDockeyAndCidForDifferentDoc(t *testing.T) { Description: "Simple all commits query with dockey and cid", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: ` { commits( @@ -44,8 +50,20 @@ func TestQueryCommitsWithDockeyAndCidForDifferentDocWithUpdate(t *testing.T) { Description: "Simple all commits query with dockey and cid", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: ` { commits( @@ -68,8 +86,20 @@ func TestQueryCommitsWithDockeyAndCid(t *testing.T) { Description: "Simple all commits query with dockey and cid", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: ` { commits( diff --git a/tests/integration/query/commits/with_dockey_count_test.go b/tests/integration/query/commits/with_dockey_count_test.go index 03d8dddeae..2bda8a7c21 100644 --- a/tests/integration/query/commits/with_dockey_count_test.go +++ b/tests/integration/query/commits/with_dockey_count_test.go @@ -21,7 +21,13 @@ func TestQueryCommitsWithDockeyAndLinkCount(t *testing.T) { Description: "Simple latest commits query with dockey and link count", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { diff --git a/tests/integration/query/commits/with_dockey_field_test.go b/tests/integration/query/commits/with_dockey_field_test.go index 0dedb1b3ef..0cbccd71fc 100644 --- a/tests/integration/query/commits/with_dockey_field_test.go +++ b/tests/integration/query/commits/with_dockey_field_test.go @@ -21,7 +21,13 @@ func TestQueryCommitsWithDockeyAndUnknownField(t *testing.T) { Description: "Simple all commits query with dockey and unknown field", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "not a field") { @@ -41,7 +47,13 @@ func TestQueryCommitsWithDockeyAndUnknownFieldId(t *testing.T) { Description: "Simple all commits query with dockey and unknown field id", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "999999") { @@ -63,7 +75,13 @@ func TestQueryCommitsWithDockeyAndField(t *testing.T) { Description: "Simple all commits query with dockey and field", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "Age") { @@ -85,7 +103,13 @@ func TestQueryCommitsWithDockeyAndFieldId(t *testing.T) { Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "1") { @@ -111,7 +135,13 @@ func TestQueryCommitsWithDockeyAndCompositeFieldId(t *testing.T) { Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "C") { diff --git a/tests/integration/query/commits/with_dockey_group_order_test.go b/tests/integration/query/commits/with_dockey_group_order_test.go new file mode 100644 index 0000000000..c5f959ce2b --- /dev/null +++ b/tests/integration/query/commits/with_dockey_group_order_test.go @@ -0,0 +1,57 @@ +// Copyright 2022 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package commits + +import ( + "testing" + + testUtils "github.com/sourcenetwork/defradb/tests/integration" +) + +func TestQueryCommitsOrderedAndGroupedByDocKey(t *testing.T) { + test := testUtils.TestCase{ + Description: "Simple all commits query, grouped and ordered by dockey", + Actions: []any{ + updateUserCollectionSchema(), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Fred", + "Age": 25 + }`, + }, + testUtils.Request{ + Request: ` { + commits(groupBy: [dockey], order: {dockey: DESC}) { + dockey + } + }`, + Results: []map[string]any{ + { + "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", + }, + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + }, + }, + }, + } + + testUtils.ExecuteTestCase(t, []string{"users"}, test) +} diff --git a/tests/integration/query/commits/with_dockey_limit_offset_test.go b/tests/integration/query/commits/with_dockey_limit_offset_test.go index f4ee0fa945..c1a8ae9e27 100644 --- a/tests/integration/query/commits/with_dockey_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_limit_offset_test.go @@ -21,10 +21,34 @@ func TestQueryCommitsWithDockeyAndLimitAndOffset(t *testing.T) { Description: "Simple all commits query with dockey, limit and offset", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), - updateAge(0, 23), - updateAge(0, 24), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 23 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 24 + }`, + }, testUtils.Request{ Request: ` { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2, offset: 1) { diff --git a/tests/integration/query/commits/with_dockey_limit_test.go b/tests/integration/query/commits/with_dockey_limit_test.go index 7e273a9ba0..7e12148986 100644 --- a/tests/integration/query/commits/with_dockey_limit_test.go +++ b/tests/integration/query/commits/with_dockey_limit_test.go @@ -21,9 +21,27 @@ func TestQueryCommitsWithDockeyAndLimit(t *testing.T) { Description: "Simple all commits query with dockey and limit", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), - updateAge(0, 23), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 23 + }`, + }, testUtils.Request{ Request: ` { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2) { diff --git a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go index 66abb03af3..fe6cd81519 100644 --- a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go @@ -21,10 +21,34 @@ func TestQueryCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { Description: "Simple all commits query with dockey, order, limit and offset", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), - updateAge(0, 23), - updateAge(0, 24), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 23 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 24 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}, limit: 2, offset: 4) { diff --git a/tests/integration/query/commits/with_dockey_order_test.go b/tests/integration/query/commits/with_dockey_order_test.go index 2cb95774e3..10e3b00306 100644 --- a/tests/integration/query/commits/with_dockey_order_test.go +++ b/tests/integration/query/commits/with_dockey_order_test.go @@ -21,8 +21,20 @@ func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { Description: "Simple all commits query with dockey, order height desc", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: DESC}) { @@ -64,8 +76,20 @@ func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { Description: "Simple all commits query with dockey, order height asc", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { @@ -107,8 +131,20 @@ func TestQueryCommitsWithDockeyAndOrderCidDesc(t *testing.T) { Description: "Simple all commits query with dockey, order cid desc", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: DESC}) { @@ -150,8 +186,20 @@ func TestQueryCommitsWithDockeyAndOrderCidAsc(t *testing.T) { Description: "Simple all commits query with dockey, order cid asc", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: ASC}) { @@ -193,10 +241,34 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { Description: "Simple all commits query with dockey, multiple updates with order cid asc", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), - updateAge(0, 23), - updateAge(0, 24), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 23 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 24 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { diff --git a/tests/integration/query/commits/with_dockey_prop_test.go b/tests/integration/query/commits/with_dockey_prop_test.go index fd5c15f218..5388218337 100644 --- a/tests/integration/query/commits/with_dockey_prop_test.go +++ b/tests/integration/query/commits/with_dockey_prop_test.go @@ -21,25 +21,27 @@ func TestQueryCommitsWithDockeyProperty(t *testing.T) { Description: "Simple commits query with dockey property", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits { - cid dockey } }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", }, }, diff --git a/tests/integration/query/commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go index 446cfc6a9c..41859e71b1 100644 --- a/tests/integration/query/commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -21,7 +21,13 @@ func TestQueryCommitsWithUnknownDockey(t *testing.T) { Description: "Simple all commits query with unknown dockey", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "unknown dockey") { @@ -41,7 +47,13 @@ func TestQueryCommitsWithDockey(t *testing.T) { Description: "Simple all commits query with dockey", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { @@ -71,7 +83,13 @@ func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { Description: "Simple all commits query with dockey, with links", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { @@ -117,8 +135,20 @@ func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { Description: "Simple all commits query with dockey, multiple results", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { @@ -163,8 +193,20 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { Description: "Simple all commits query with dockey, multiple results and links", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { diff --git a/tests/integration/query/commits/with_dockey_typename_test.go b/tests/integration/query/commits/with_dockey_typename_test.go index 612fe318fd..0bf5332c30 100644 --- a/tests/integration/query/commits/with_dockey_typename_test.go +++ b/tests/integration/query/commits/with_dockey_typename_test.go @@ -21,7 +21,13 @@ func TestQueryCommitsWithDockeyWithTypeName(t *testing.T) { Description: "Simple all commits query with dockey and typename", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { diff --git a/tests/integration/query/commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go index 45a49afd6b..77bc64ba3b 100644 --- a/tests/integration/query/commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -23,7 +23,13 @@ func TestQueryCommitsWithField(t *testing.T) { Description: "Simple all commits query with field", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits (field: "Age") { @@ -45,7 +51,13 @@ func TestQueryCommitsWithFieldId(t *testing.T) { Description: "Simple all commits query with field id", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits (field: "1") { @@ -71,7 +83,13 @@ func TestQueryCommitsWithCompositeFieldId(t *testing.T) { Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(field: "C") { @@ -97,7 +115,13 @@ func TestQueryCommitsWithCompositeFieldIdWithReturnedSchemaVersionId(t *testing. Description: "Simple all commits query with dockey and field id", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: `query { commits(field: "C") { diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index 13d3adeede..d8b4e0e9ce 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -21,8 +21,20 @@ func TestQueryCommitsWithGroupBy(t *testing.T) { Description: "Simple all commits query, group by height", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: ` { commits(groupBy: [height]) { @@ -49,8 +61,20 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { Description: "Simple all commits query, group by height", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - updateAge(0, 22), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, testUtils.Request{ Request: ` { commits(groupBy: [height]) { @@ -100,7 +124,13 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { Description: "Simple all commits query, group by cid", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, testUtils.Request{ Request: ` { commits(groupBy: [cid]) { @@ -148,10 +178,34 @@ func TestQueryCommitsWithGroupByDocKey(t *testing.T) { Description: "Simple all commits query, group by dockey", Actions: []any{ updateUserCollectionSchema(), - createDoc("John", 21), - createDoc("Fred", 25), - updateAge(0, 22), - updateAge(1, 26), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "Fred", + "Age": 25 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 0, + Doc: `{ + "Age": 22 + }`, + }, + testUtils.UpdateDoc{ + CollectionID: 0, + DocID: 1, + Doc: `{ + "Age": 26 + }`, + }, testUtils.Request{ Request: ` { commits(groupBy: [dockey]) { @@ -172,31 +226,3 @@ func TestQueryCommitsWithGroupByDocKey(t *testing.T) { testUtils.ExecuteTestCase(t, []string{"users"}, test) } - -func TestQueryCommitsWithOrderedByDocKey(t *testing.T) { - test := testUtils.TestCase{ - Description: "Simple all commits query, grouped and ordered by height", - Actions: []any{ - updateUserCollectionSchema(), - createDoc("John", 21), - createDoc("Fred", 25), - testUtils.Request{ - Request: ` { - commits(groupBy: [dockey], order: {dockey: DESC}) { - dockey - } - }`, - Results: []map[string]any{ - { - "dockey": "bae-b2103437-f5bd-52b6-99b1-5970412c5201", - }, - { - "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", - }, - }, - }, - }, - } - - testUtils.ExecuteTestCase(t, []string{"users"}, test) -} From 2910d69d39d8827fb35a3f80e0b7acb856bce7a8 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 24 Mar 2023 14:39:31 +0100 Subject: [PATCH 16/21] Fix typos --- core/key.go | 2 +- db/collection.go | 2 +- planner/commit.go | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/key.go b/core/key.go index edd8f6e3cf..ff0a47b4ea 100644 --- a/core/key.go +++ b/core/key.go @@ -123,7 +123,7 @@ type ReplicatorKey struct { var _ Key = (*ReplicatorKey)(nil) // Creates a new DataStoreKey from a string as best as it can, -// splitting the input using '/' as a field deliminater. It assumes +// splitting the input using '/' as a field deliminator. It assumes // that the input string is in the following format: // // /[CollectionId]/[InstanceType]/[DocKey]/[FieldId] diff --git a/db/collection.go b/db/collection.go index 4342543627..102b874336 100644 --- a/db/collection.go +++ b/db/collection.go @@ -255,7 +255,7 @@ func (db *db) updateCollection( // validateUpdateCollection validates that the given collection description is a valid update. // -// Will return true if the given desctiption differs from the current persisted state of the +// Will return true if the given description differs from the current persisted state of the // collection. Will return an error if it fails validation. func (db *db) validateUpdateCollection( ctx context.Context, diff --git a/planner/commit.go b/planner/commit.go index 8a6a3cfc2a..dd42c02873 100644 --- a/planner/commit.go +++ b/planner/commit.go @@ -123,21 +123,21 @@ func (n *dagScanNode) Source() planNode { return nil } func (n *dagScanNode) Explain() (map[string]any, error) { explainerMap := map[string]any{} - // Add the field attribute to the explaination if it exists. + // Add the field attribute to the explanation if it exists. if n.commitSelect.FieldName.HasValue() { explainerMap["field"] = n.commitSelect.FieldName.Value() } else { explainerMap["field"] = nil } - // Add the cid attribute to the explaination if it exists. + // Add the cid attribute to the explanation if it exists. if n.commitSelect.Cid.HasValue() { explainerMap["cid"] = n.commitSelect.Cid.Value() } else { explainerMap["cid"] = nil } - // Build the explaination of the spans attribute. + // Build the explanation of the spans attribute. spansExplainer := []map[string]any{} // Note: n.headset is `nil` for single commit selection query, so must check for it. if n.spans.HasValue { @@ -294,14 +294,15 @@ func (n *dagScanNode) dagBlockToNodeDoc(block blocks.Block) (core.Doc, []*ipld.L n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "delta", delta["Data"]) dockey, ok := delta["DocKey"].([]byte) - if ok { - dockeyObj, err := core.NewDataStoreKey(string(dockey)) - if err != nil { - return core.Doc{}, nil, err - } - n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "dockey", - string(dockeyObj.InstanceType)) + if !ok { + return core.Doc{}, nil, ErrDeltaMissingDockey + } + + dockeyObj, err := core.NewDataStoreKey(string(dockey)) + if err != nil { + return core.Doc{}, nil, err } + n.commitSelect.DocumentMapping.SetFirstOfName(&commit, "dockey", dockeyObj.DocKey) heads := make([]*ipld.Link, 0) From dc034a82ae4bcd99372b82a24e846b9aead7c4b0 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 24 Mar 2023 14:40:53 +0100 Subject: [PATCH 17/21] Store dockey with value in block storage --- core/crdt/composite.go | 2 +- core/crdt/lwwreg.go | 2 +- planner/errors.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/crdt/composite.go b/core/crdt/composite.go index 0b6c6e678b..8edfc1e5f1 100644 --- a/core/crdt/composite.go +++ b/core/crdt/composite.go @@ -121,7 +121,7 @@ func (c CompositeDAG) Set(patch []byte, links []core.DAGLink) *CompositeDAGDelta }) return &CompositeDAGDelta{ Data: patch, - DocKey: c.key.Bytes(), + DocKey: c.key.WithValueFlag().Bytes(), SubDAGs: links, SchemaVersionID: c.schemaVersionKey.SchemaVersionId, } diff --git a/core/crdt/lwwreg.go b/core/crdt/lwwreg.go index 264316a00b..dc9ab0df60 100644 --- a/core/crdt/lwwreg.go +++ b/core/crdt/lwwreg.go @@ -118,7 +118,7 @@ func (reg LWWRegister) Set(value []byte) *LWWRegDelta { // return NewLWWRegister(reg.id, value, reg.clock.Apply(), reg.clock) return &LWWRegDelta{ Data: value, - DocKey: reg.key.Bytes(), + DocKey: reg.key.WithValueFlag().Bytes(), SchemaVersionID: reg.schemaVersionKey.SchemaVersionId, } } diff --git a/planner/errors.go b/planner/errors.go index a0ceec5dc3..720f3b2844 100644 --- a/planner/errors.go +++ b/planner/errors.go @@ -19,6 +19,7 @@ const ( var ( ErrDeltaMissingPriority = errors.New("commit Delta missing priority key") + ErrDeltaMissingDockey = errors.New("commit Delta missing dockey") ErrFailedToFindScanNode = errors.New("failed to find original scan node in plan graph") ErrMissingQueryOrMutation = errors.New("request is missing query or mutation operation statements") ErrOperationDefinitionMissingSelection = errors.New("operationDefinition is missing selections") From 4178ebc27fceff93bfa858dd0f371a1fb87d11cf Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 24 Mar 2023 14:44:00 +0100 Subject: [PATCH 18/21] Adjust CIDs in all tests --- .../events/simple/with_update_test.go | 4 +- .../simple/create/with_version_test.go | 2 +- .../integration/query/commits/simple_test.go | 24 +++---- .../query/commits/with_cid_test.go | 8 +-- .../query/commits/with_depth_test.go | 36 +++++----- .../query/commits/with_dockey_cid_test.go | 4 +- .../query/commits/with_dockey_count_test.go | 6 +- .../query/commits/with_dockey_field_test.go | 4 +- .../commits/with_dockey_limit_offset_test.go | 4 +- .../query/commits/with_dockey_limit_test.go | 4 +- .../with_dockey_order_limit_offset_test.go | 4 +- .../query/commits/with_dockey_order_test.go | 66 +++++++++---------- .../query/commits/with_dockey_test.go | 46 ++++++------- .../commits/with_dockey_typename_test.go | 6 +- .../query/commits/with_field_test.go | 6 +- .../query/commits/with_group_test.go | 16 ++--- .../latest_commits/with_dockey_field_test.go | 8 +-- .../query/latest_commits/with_dockey_test.go | 8 +-- .../query/one_to_many/with_cid_dockey_test.go | 8 +-- .../query/simple/with_cid_dockey_test.go | 10 +-- .../query/simple/with_version_test.go | 20 +++--- 21 files changed, 149 insertions(+), 145 deletions(-) diff --git a/tests/integration/events/simple/with_update_test.go b/tests/integration/events/simple/with_update_test.go index d1659cec49..3b1d6e01b1 100644 --- a/tests/integration/events/simple/with_update_test.go +++ b/tests/integration/events/simple/with_update_test.go @@ -64,14 +64,14 @@ func TestEventsSimpleWithUpdate(t *testing.T) { ExpectedUpdates: []testUtils.ExpectedUpdate{ { DocKey: immutable.Some(docKey1), - Cid: immutable.Some("bafybeickwwj3ycxexdnslgftwnoozdeezk2puorpmulk2csznmd7o4xgmi"), + Cid: immutable.Some("bafybeidjua7bjh6txc5k6mzne2bnglp2kz2goglofof7c5pmuonrcmeso4"), }, { DocKey: immutable.Some(docKey2), }, { DocKey: immutable.Some(docKey1), - Cid: immutable.Some("bafybeibtiwjbb6ftknifwh3vm5xykfq4pi5lpxekqs6cs6o3o2dgtnjjxa"), + Cid: immutable.Some("bafybeieczcnnpbwb5vctvnk7yiuhf5botch6kiw3y2qgfs2zkngu5f7ju4"), }, }, } diff --git a/tests/integration/mutation/simple/create/with_version_test.go b/tests/integration/mutation/simple/create/with_version_test.go index 36cc20e1fc..7664b14711 100644 --- a/tests/integration/mutation/simple/create/with_version_test.go +++ b/tests/integration/mutation/simple/create/with_version_test.go @@ -31,7 +31,7 @@ func TestMutationCreateSimpleReturnVersionCID(t *testing.T) { { "_version": []map[string]any{ { - "cid": "bafybeictevbrytwpeyvd4dsx57jl7saop7i3oppq4hcauz3a66ll2chwty", + "cid": "bafybeig2pgnjph56u3pbj7cqhhoelhfhmtlab3ntrh3yfdbqsgwywitxme", }, }, }, diff --git a/tests/integration/query/commits/simple_test.go b/tests/integration/query/commits/simple_test.go index 94b60a090b..38aa80978a 100644 --- a/tests/integration/query/commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -36,13 +36,13 @@ func TestQueryCommits(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, @@ -79,22 +79,22 @@ func TestQueryCommitsMultipleDocs(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeih23ppd7pcp2rbuntybstbt6hwhg4qqeoxl4hfelehmpxmljvtysm", + "cid": "bafybeibga7z63ol3yywevh6w3ybohszjqcalsb2m72w5tn6ukt7f3qbhfm", }, { - "cid": "bafybeifycjhxcrn3kspu3tajpk2qvlto5mmaxx22bb2tk5ly6dbhc43p5u", + "cid": "bafybeihldaumjvn55gnvydiupp4dtdjqdusjsprokwmqhtmazoaknpc3k4", }, { - "cid": "bafybeidzzv4pnmx4xzfopyznmud6swrh2labbvsczpnqjvshqqkrgrc2uu", + "cid": "bafybeidknf63hk7ixsq5ymh5emsnt47pr3bmly7vilzho763oahibnjuqi", }, { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, @@ -125,15 +125,15 @@ func TestQueryCommitsWithSchemaVersionIdField(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, }, diff --git a/tests/integration/query/commits/with_cid_test.go b/tests/integration/query/commits/with_cid_test.go index 1c40237723..cd7e4a631e 100644 --- a/tests/integration/query/commits/with_cid_test.go +++ b/tests/integration/query/commits/with_cid_test.go @@ -38,14 +38,14 @@ func TestQueryCommitsWithCid(t *testing.T) { testUtils.Request{ Request: `query { commits( - cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" + cid: "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq" ) { cid } }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, }, }, @@ -71,14 +71,14 @@ func TestQueryCommitsWithCidForFieldCommit(t *testing.T) { testUtils.Request{ Request: `query { commits( - cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" + cid: "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq" ) { cid } }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, }, }, diff --git a/tests/integration/query/commits/with_depth_test.go b/tests/integration/query/commits/with_depth_test.go index 016760e9f4..a4c061908d 100644 --- a/tests/integration/query/commits/with_depth_test.go +++ b/tests/integration/query/commits/with_depth_test.go @@ -36,13 +36,13 @@ func TestQueryCommitsWithDepth1(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, @@ -80,17 +80,17 @@ func TestQueryCommitsWithDepth1WithUpdate(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + // "Age" field head + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { // "Name" field head (unchanged from create) - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - // "Age" field head - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, }, @@ -137,27 +137,27 @@ func TestQueryCommitsWithDepth2WithUpdate(t *testing.T) { Results: []map[string]any{ { // Composite head - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "cid": "bafybeihvifwxwmfuyeupebhkalie5odlafnzdjpmwqz5kuo5zld63ishve", "height": int64(3), }, { // Composite head -1 - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { // "Name" field head (unchanged from create) - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { // "Age" field head - "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", + "cid": "bafybeif66vvvkq4o4lj4hc5hu533lwtuts7qbhw6oan7kx4rqlscw7jkga", "height": int64(3), }, { // "Age" field head -1 - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, }, @@ -195,22 +195,22 @@ func TestQueryCommitsWithDepth1AndMultipleDocs(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, { - "cid": "bafybeie4ciqu6dwoovbrzjuzlpy6ene3ahhiqz7ocrcxeb2h4zkifhqdr4", + "cid": "bafybeigio6tiay2dm2wj4fvmrqzzdgyqqsakjzljerq57dwpm547s2gazq", }, { - "cid": "bafybeifj66t5p5df7ksiod6asvyyk6zduejzd7pncbpnaospn5mmjdr5bq", + "cid": "bafybeiewcnxpeevov7xstc67eh26utlerftxrq5qi2exj5slpz6pu2rxtm", }, { - "cid": "bafybeielpy36cijvx3ffpq3oxd4knmui7h5hrruvcb5it4homf5krylpsi", + "cid": "bafybeie3ozbpbhzxz57t7vminmwzttmbhfnktmua62eimdnbux4yupxzi4", }, }, }, diff --git a/tests/integration/query/commits/with_dockey_cid_test.go b/tests/integration/query/commits/with_dockey_cid_test.go index e72730048e..7d2975aea1 100644 --- a/tests/integration/query/commits/with_dockey_cid_test.go +++ b/tests/integration/query/commits/with_dockey_cid_test.go @@ -104,14 +104,14 @@ func TestQueryCommitsWithDockeyAndCid(t *testing.T) { Request: ` { commits( dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", - cid: "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m" + cid: "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq" ) { cid } }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, }, }, diff --git a/tests/integration/query/commits/with_dockey_count_test.go b/tests/integration/query/commits/with_dockey_count_test.go index 2bda8a7c21..65b073c332 100644 --- a/tests/integration/query/commits/with_dockey_count_test.go +++ b/tests/integration/query/commits/with_dockey_count_test.go @@ -37,15 +37,15 @@ func TestQueryCommitsWithDockeyAndLinkCount(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "_count": 0, }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "_count": 0, }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "_count": 2, }, }, diff --git a/tests/integration/query/commits/with_dockey_field_test.go b/tests/integration/query/commits/with_dockey_field_test.go index 0cbccd71fc..7215c56c27 100644 --- a/tests/integration/query/commits/with_dockey_field_test.go +++ b/tests/integration/query/commits/with_dockey_field_test.go @@ -118,7 +118,7 @@ func TestQueryCommitsWithDockeyAndFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, }, }, @@ -150,7 +150,7 @@ func TestQueryCommitsWithDockeyAndCompositeFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, diff --git a/tests/integration/query/commits/with_dockey_limit_offset_test.go b/tests/integration/query/commits/with_dockey_limit_offset_test.go index c1a8ae9e27..4a251651ea 100644 --- a/tests/integration/query/commits/with_dockey_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_limit_offset_test.go @@ -57,10 +57,10 @@ func TestQueryCommitsWithDockeyAndLimitAndOffset(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "cid": "bafybeihvifwxwmfuyeupebhkalie5odlafnzdjpmwqz5kuo5zld63ishve", }, { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", }, }, }, diff --git a/tests/integration/query/commits/with_dockey_limit_test.go b/tests/integration/query/commits/with_dockey_limit_test.go index 7e12148986..288f3b78e4 100644 --- a/tests/integration/query/commits/with_dockey_limit_test.go +++ b/tests/integration/query/commits/with_dockey_limit_test.go @@ -50,10 +50,10 @@ func TestQueryCommitsWithDockeyAndLimit(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "cid": "bafybeihvifwxwmfuyeupebhkalie5odlafnzdjpmwqz5kuo5zld63ishve", }, { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", }, }, }, diff --git a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go index fe6cd81519..942368fd77 100644 --- a/tests/integration/query/commits/with_dockey_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go @@ -58,11 +58,11 @@ func TestQueryCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "cid": "bafybeihvifwxwmfuyeupebhkalie5odlafnzdjpmwqz5kuo5zld63ishve", "height": int64(3), }, }, diff --git a/tests/integration/query/commits/with_dockey_order_test.go b/tests/integration/query/commits/with_dockey_order_test.go index 10e3b00306..6cf6e6e990 100644 --- a/tests/integration/query/commits/with_dockey_order_test.go +++ b/tests/integration/query/commits/with_dockey_order_test.go @@ -44,23 +44,23 @@ func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "height": int64(1), }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "height": int64(1), }, }, @@ -99,23 +99,23 @@ func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "height": int64(1), }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "height": int64(1), }, { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, }, @@ -154,24 +154,24 @@ func TestQueryCommitsWithDockeyAndOrderCidDesc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", + "height": int64(1), }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "height": int64(1), }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", + "height": int64(2), }, }, }, @@ -209,24 +209,24 @@ func TestQueryCommitsWithDockeyAndOrderCidAsc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", - "height": int64(1), + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", + "height": int64(2), }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "height": int64(1), }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", - "height": int64(2), + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", + "height": int64(1), }, }, }, @@ -278,39 +278,39 @@ func TestQueryCommitsWithDockeyAndOrderAndMultiUpdatesCidAsc(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "height": int64(1), }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "height": int64(1), }, { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, { - "cid": "bafybeifaxl4u5wmokgr4jviru6dz7teg7f2fomusxrvh7o5nh2a32jk3va", + "cid": "bafybeihvifwxwmfuyeupebhkalie5odlafnzdjpmwqz5kuo5zld63ishve", "height": int64(3), }, { - "cid": "bafybeieh6icybinqmuz7or7nqjt445zu2qbnxccuu64i5jhgonhlj2k5sy", + "cid": "bafybeif66vvvkq4o4lj4hc5hu533lwtuts7qbhw6oan7kx4rqlscw7jkga", "height": int64(3), }, { - "cid": "bafybeic4slf53yiert4jrdeyvqij3rnat2iikgbn7fdn6n6zowu66dylbi", + "cid": "bafybeibh6emehgfltcpgdw4a45icilhgqtdtxsexnmgx2pjv742ljyrqmu", "height": int64(4), }, { - "cid": "bafybeic4rhgl4pvsh3z5rtr5tzm3zzakyivju6mqemq5v4xqxh7otgrjri", + "cid": "bafybeidnq2bftgibf3qqikpaknptq2pcupuhx5zqp56lawmtq3ehjhuy3u", "height": int64(4), }, }, diff --git a/tests/integration/query/commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go index 41859e71b1..c0bf83161b 100644 --- a/tests/integration/query/commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -62,13 +62,13 @@ func TestQueryCommitsWithDockey(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, @@ -102,22 +102,22 @@ func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "links": []map[string]any{}, }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "links": []map[string]any{}, }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "links": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "name": "Age", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "name": "Name", }, }, @@ -158,23 +158,23 @@ func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "height": int64(2), }, { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "height": int64(1), }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "height": int64(1), }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "height": int64(2), }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "height": int64(1), }, }, @@ -219,44 +219,44 @@ func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "links": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "name": "_head", }, }, }, { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "links": []map[string]any{}, }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "links": []map[string]any{}, }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", "links": []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", "name": "Age", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "name": "_head", }, }, }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "links": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "name": "Age", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "name": "Name", }, }, diff --git a/tests/integration/query/commits/with_dockey_typename_test.go b/tests/integration/query/commits/with_dockey_typename_test.go index 0bf5332c30..644de3e39c 100644 --- a/tests/integration/query/commits/with_dockey_typename_test.go +++ b/tests/integration/query/commits/with_dockey_typename_test.go @@ -37,15 +37,15 @@ func TestQueryCommitsWithDockeyWithTypeName(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "__typename": "Commit", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "__typename": "Commit", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "__typename": "Commit", }, }, diff --git a/tests/integration/query/commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go index 77bc64ba3b..534a66b17d 100644 --- a/tests/integration/query/commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -66,7 +66,7 @@ func TestQueryCommitsWithFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, }, }, @@ -98,7 +98,7 @@ func TestQueryCommitsWithCompositeFieldId(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, @@ -131,7 +131,7 @@ func TestQueryCommitsWithCompositeFieldIdWithReturnedSchemaVersionId(t *testing. }`, Results: []map[string]any{ { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, }, diff --git a/tests/integration/query/commits/with_group_test.go b/tests/integration/query/commits/with_group_test.go index d8b4e0e9ce..0e357ebf9a 100644 --- a/tests/integration/query/commits/with_group_test.go +++ b/tests/integration/query/commits/with_group_test.go @@ -89,10 +89,10 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { "height": int64(2), "_group": []map[string]any{ { - "cid": "bafybeihxc6ittcok3rnetguamxfzd3wa534z7zwqsaoppvawu7jx4rdy5u", + "cid": "bafybeigtudzrntyslfdtukiobzen76iuhkmyo3x4eutx3igwzwhjekp2oi", }, { - "cid": "bafybeidxeexqpsbf2qqrrkrysdztf2q5mqfwabwrcxdkjuolf6fsyzzyh4", + "cid": "bafybeibwql353y3bpl24f25t53gl6zxcsp56uvmdrqrvweh6kv63un4pca", }, }, }, @@ -100,13 +100,13 @@ func TestQueryCommitsWithGroupByHeightWithChild(t *testing.T) { "height": int64(1), "_group": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", }, }, }, @@ -142,7 +142,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }`, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "_group": []map[string]any{ { "height": int64(1), @@ -150,7 +150,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }, }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "_group": []map[string]any{ { "height": int64(1), @@ -158,7 +158,7 @@ func TestQueryCommitsWithGroupByCidWithChild(t *testing.T) { }, }, { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "_group": []map[string]any{ { "height": int64(1), diff --git a/tests/integration/query/latest_commits/with_dockey_field_test.go b/tests/integration/query/latest_commits/with_dockey_field_test.go index 7b2f2fc92b..f5719a3ff7 100644 --- a/tests/integration/query/latest_commits/with_dockey_field_test.go +++ b/tests/integration/query/latest_commits/with_dockey_field_test.go @@ -68,7 +68,7 @@ func TestQueryLatestCommitsWithDocKeyAndFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "links": []map[string]any{}, }, }, @@ -101,14 +101,14 @@ func TestQueryLatestCommitsWithDocKeyAndCompositeFieldId(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "links": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "name": "Age", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "name": "Name", }, }, diff --git a/tests/integration/query/latest_commits/with_dockey_test.go b/tests/integration/query/latest_commits/with_dockey_test.go index 68bdfea029..97e4563a7a 100644 --- a/tests/integration/query/latest_commits/with_dockey_test.go +++ b/tests/integration/query/latest_commits/with_dockey_test.go @@ -38,14 +38,14 @@ func TestQueryLatestCommitsWithDocKey(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "links": []map[string]any{ { - "cid": "bafybeiaeic6vhiiw5zu6ju7e47cclvctn6t5pb36fj3mczchyhmctbrr6m", + "cid": "bafybeih7athlviqvv255ujgk6mikxcwxp46n7yyaekxldrgsvgrkrgajtq", "name": "Age", }, { - "cid": "bafybeibsaubd2ptp6qqsszv24p73j474amc4pll4oyssnpilofrl575hmy", + "cid": "bafybeifez5xzi6x4w6cahxzlhsjbzbarzgtoixfioqr5l4uh2akkgl6hhq", "name": "Name", }, }, @@ -75,7 +75,7 @@ func TestQueryLatestCommitsWithDocKeyWithSchemaVersionIdField(t *testing.T) { }, Results: []map[string]any{ { - "cid": "bafybeidcatznm2mlsymcytrh5fkpdrazensg5fsvn2uavcgiq2bf26lzey", + "cid": "bafybeig32cpgkhikjerzp33wvbilrcbhm7xqpjeba5ptpgg2s5ivqlndba", "schemaVersionId": "bafkreibwyhaiseplil6tayn7spazp3qmc7nkoxdjb7uoe5zvcac4pgbwhy", }, }, diff --git a/tests/integration/query/one_to_many/with_cid_dockey_test.go b/tests/integration/query/one_to_many/with_cid_dockey_test.go index 8482c26a0d..a8c3625201 100644 --- a/tests/integration/query/one_to_many/with_cid_dockey_test.go +++ b/tests/integration/query/one_to_many/with_cid_dockey_test.go @@ -68,7 +68,7 @@ func TestQueryOneToManyWithCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with cid and dockey", Request: `query { book ( - cid: "bafybeid7tx5fhjcekoly2cckw2kb46buuvqslv5r3hzmcl36ji7o2hhnhi", + cid: "bafybeieby4hopjxof5cx7pkfrk7qvv7vy7s4i37mzdlcp2dk2m37jouycm" dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name @@ -117,7 +117,7 @@ func TestQueryOneToManyWithChildUpdateAndFirstCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with child update and parent cid and dockey", Request: `query { book ( - cid: "bafybeid7tx5fhjcekoly2cckw2kb46buuvqslv5r3hzmcl36ji7o2hhnhi", + cid: "bafybeieby4hopjxof5cx7pkfrk7qvv7vy7s4i37mzdlcp2dk2m37jouycm", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name @@ -173,7 +173,7 @@ func TestQueryOneToManyWithParentUpdateAndFirstCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with parent update and parent cid and dockey", Request: `query { book ( - cid: "bafybeid7tx5fhjcekoly2cckw2kb46buuvqslv5r3hzmcl36ji7o2hhnhi", + cid: "bafybeieby4hopjxof5cx7pkfrk7qvv7vy7s4i37mzdlcp2dk2m37jouycm", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name @@ -229,7 +229,7 @@ func TestQueryOneToManyWithParentUpdateAndLastCidAndDocKey(t *testing.T) { Description: "One-to-many relation query from one side with parent update and parent cid and dockey", Request: `query { book ( - cid: "bafybeidaovkvq5yvwolbeugeceyzuut2wqojul44ituacjvemdpqugekwa", + cid: "bafybeieutgrc67hwomdleoixikuygznnzmsrvvby6jloyqkkakfnnra2ha", dockey: "bae-fd541c25-229e-5280-b44b-e5c2af3e374d" ) { name diff --git a/tests/integration/query/simple/with_cid_dockey_test.go b/tests/integration/query/simple/with_cid_dockey_test.go index 5bd6cefa68..292f9b2c7f 100644 --- a/tests/integration/query/simple/with_cid_dockey_test.go +++ b/tests/integration/query/simple/with_cid_dockey_test.go @@ -73,7 +73,7 @@ func TestQuerySimpleWithCidAndDocKey(t *testing.T) { Description: "Simple query with cid and dockey", Request: `query { users ( - cid: "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", + cid: "bafybeiekrh5ixb6obq6hcs55rwychiwmoen63ozvga7r2hvedc2qk7oe2e", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -102,7 +102,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocKey(t *testing.T) { Description: "Simple query with (first) cid and dockey", Request: `query { users ( - cid: "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", + cid: "bafybeiekrh5ixb6obq6hcs55rwychiwmoen63ozvga7r2hvedc2qk7oe2e", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -143,7 +143,7 @@ func TestQuerySimpleWithUpdateAndLastCidAndDocKey(t *testing.T) { Description: "Simple query with (last) cid and dockey", Request: `query { users ( - cid: "bafybeig2exzgeuq2ctwhxyxq4ucosgxanw3nzhodetq2sclo5lvdyavk5m", + cid: "bafybeiejwvu4aaq6ai5gyv6efm3p5i7acuplo5vkpxwzewzvae6ikbthea", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -184,7 +184,7 @@ func TestQuerySimpleWithUpdateAndMiddleCidAndDocKey(t *testing.T) { Description: "Simple query with (middle) cid and dockey", Request: `query { users ( - cid: "bafybeibjmbeb6olbio3getfvotoe3l3krljd5pceqbr3cx4nf3o2wv5t54", + cid: "bafybeieznxu333hiymi25qd7vox6iytvfrc3asxvdgraqjvumenjydkf5m", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name @@ -225,7 +225,7 @@ func TestQuerySimpleWithUpdateAndFirstCidAndDocKeyAndSchemaVersion(t *testing.T) Description: "Simple query with (first) cid and dockey and yielded schema version", Request: `query { users ( - cid: "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", + cid: "bafybeiekrh5ixb6obq6hcs55rwychiwmoen63ozvga7r2hvedc2qk7oe2e", dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" ) { Name diff --git a/tests/integration/query/simple/with_version_test.go b/tests/integration/query/simple/with_version_test.go index c7c913038b..fe3f544b50 100644 --- a/tests/integration/query/simple/with_version_test.go +++ b/tests/integration/query/simple/with_version_test.go @@ -46,14 +46,14 @@ func TestQuerySimpleWithEmbeddedLatestCommit(t *testing.T) { "Age": uint64(21), "_version": []map[string]any{ { - "cid": "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", + "cid": "bafybeiekrh5ixb6obq6hcs55rwychiwmoen63ozvga7r2hvedc2qk7oe2e", "links": []map[string]any{ { - "cid": "bafybeihbnch3akfu22wlbq3es7vudxev5ymo2deq2inknxhbpoacd7x5aq", + "cid": "bafybeicroiodf5qn46wx72zlusxhymafhxrgdrrt5ufp7bnybzw4nf4ntu", "name": "Age", }, { - "cid": "bafybeib6ujnjsuox6fnzrwoepvyobyxk26hlczefwrv2myuefbenlglyzy", + "cid": "bafybeiboaciru4wshhoyfto4mfpzihevlvuvxmno2fhu5kk3svotdr7z3y", "name": "Name", }, }, @@ -101,11 +101,14 @@ func TestQuerySimpleWithEmbeddedLatestCommitWithSchemaVersionId(t *testing.T) { } func TestQuerySimpleWithEmbeddedLatestCommitWithDockey(t *testing.T) { + const dockey = "bae-52b9170d-b77a-5887-b877-cbdbb99b009f" + test := testUtils.RequestTestCase{ - Description: "Embedded commits query within object query with schema version id", + Description: "Embedded commits query within object query with dockey", Request: `query { users { Name + _key _version { dockey } @@ -122,9 +125,10 @@ func TestQuerySimpleWithEmbeddedLatestCommitWithDockey(t *testing.T) { Results: []map[string]any{ { "Name": "John", + "_key": dockey, "_version": []map[string]any{ { - "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + "dockey": dockey, }, }, }, @@ -167,14 +171,14 @@ func TestQuerySimpleWithMultipleAliasedEmbeddedLatestCommit(t *testing.T) { "Age": uint64(21), "_version": []map[string]any{ { - "cid": "bafybeidb2ddr5o374hkaf5m6ziihucwn4lhzhyzi3dddj3afgfpu7p7tb4", + "cid": "bafybeiekrh5ixb6obq6hcs55rwychiwmoen63ozvga7r2hvedc2qk7oe2e", "L1": []map[string]any{ { - "cid": "bafybeihbnch3akfu22wlbq3es7vudxev5ymo2deq2inknxhbpoacd7x5aq", + "cid": "bafybeicroiodf5qn46wx72zlusxhymafhxrgdrrt5ufp7bnybzw4nf4ntu", "name": "Age", }, { - "cid": "bafybeib6ujnjsuox6fnzrwoepvyobyxk26hlczefwrv2myuefbenlglyzy", + "cid": "bafybeiboaciru4wshhoyfto4mfpzihevlvuvxmno2fhu5kk3svotdr7z3y", "name": "Name", }, }, From 10b56ad911e86fb21153a27ab3516817792a344b Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 24 Mar 2023 14:54:36 +0100 Subject: [PATCH 19/21] Add breaking change file --- docs/data_format_changes/i846-add-dockey-to-blocks.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/data_format_changes/i846-add-dockey-to-blocks.md diff --git a/docs/data_format_changes/i846-add-dockey-to-blocks.md b/docs/data_format_changes/i846-add-dockey-to-blocks.md new file mode 100644 index 0000000000..6eaa6f69f4 --- /dev/null +++ b/docs/data_format_changes/i846-add-dockey-to-blocks.md @@ -0,0 +1,6 @@ +# Store dockey filed to delta (block) storage + +To be able to request dockey field on commits, it had to be stored first. +Composite blocks didn't have dockey field, so it was added to the block struct. +Field blocks had dockey field, but it didn't store the key with it's instance type. +That's why all CIDs of commits needed to be regenerated. \ No newline at end of file From 33e0d51e169a903a4758c9f6510f59f4e4758e69 Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 24 Mar 2023 15:10:24 +0100 Subject: [PATCH 20/21] Add test for latest_commits --- .../integration/query/latest_commits/utils.go | 6 +++ .../latest_commits/with_dockey_prop_test.go | 47 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/integration/query/latest_commits/with_dockey_prop_test.go diff --git a/tests/integration/query/latest_commits/utils.go b/tests/integration/query/latest_commits/utils.go index fcb646e47c..3bfb24d15b 100644 --- a/tests/integration/query/latest_commits/utils.go +++ b/tests/integration/query/latest_commits/utils.go @@ -24,6 +24,12 @@ var userCollectionGQLSchema = (` } `) +func updateUserCollectionSchema() testUtils.SchemaUpdate { + return testUtils.SchemaUpdate{ + Schema: userCollectionGQLSchema, + } +} + func executeTestCase(t *testing.T, test testUtils.RequestTestCase) { testUtils.ExecuteRequestTestCase(t, userCollectionGQLSchema, []string{"users"}, test) } diff --git a/tests/integration/query/latest_commits/with_dockey_prop_test.go b/tests/integration/query/latest_commits/with_dockey_prop_test.go new file mode 100644 index 0000000000..90e94a83fe --- /dev/null +++ b/tests/integration/query/latest_commits/with_dockey_prop_test.go @@ -0,0 +1,47 @@ +// Copyright 2022 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package latest_commits + +import ( + "testing" + + testUtils "github.com/sourcenetwork/defradb/tests/integration" +) + +func TestQueryLastCommitsWithDockeyProperty(t *testing.T) { + test := testUtils.TestCase{ + Description: "Simple latest commits query with dockey property", + Actions: []any{ + updateUserCollectionSchema(), + testUtils.CreateDoc{ + CollectionID: 0, + Doc: `{ + "Name": "John", + "Age": 21 + }`, + }, + testUtils.Request{ + Request: `query { + latestCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + dockey + } + }`, + Results: []map[string]any{ + { + "dockey": "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", + }, + }, + }, + }, + } + + testUtils.ExecuteTestCase(t, []string{"users"}, test) +} From dd6c9a42f0210e7a090a71615be886e9adad46fc Mon Sep 17 00:00:00 2001 From: Islam Aliev Date: Fri, 24 Mar 2023 16:54:03 +0100 Subject: [PATCH 21/21] Fix typo --- docs/data_format_changes/i846-add-dockey-to-blocks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/data_format_changes/i846-add-dockey-to-blocks.md b/docs/data_format_changes/i846-add-dockey-to-blocks.md index 6eaa6f69f4..1b04df649d 100644 --- a/docs/data_format_changes/i846-add-dockey-to-blocks.md +++ b/docs/data_format_changes/i846-add-dockey-to-blocks.md @@ -1,6 +1,6 @@ -# Store dockey filed to delta (block) storage +# Store dockey field to delta (block) storage -To be able to request dockey field on commits, it had to be stored first. +To be able to request dockey field on commits, it had to be stored first. Composite blocks didn't have dockey field, so it was added to the block struct. Field blocks had dockey field, but it didn't store the key with it's instance type. -That's why all CIDs of commits needed to be regenerated. \ No newline at end of file +That's why all CIDs of commits needed to be regenerated.