From 78699861a8399b0fb89b02c9f38ae5c6dabb3274 Mon Sep 17 00:00:00 2001 From: AndrewSisley Date: Tue, 11 Oct 2022 10:47:24 -0400 Subject: [PATCH] refactor: Remove commit query (#841) * Port commit tests with feature parity to allCommits Moves the commit query tests that do not exist for allCommits, where the behaviour matches exactly (copy-paste with name changes). * Port commit tests with corrected behaviour Moves the commit test(s) to allCommits where the behaviour of commit was incorrect, but correct in allCommits, and where allCommits was previously untested. * Remove commit tests that already exist for allCommits Removes commit tests for behaviour that is already tested by existing commit tests. * Remove commit test that is not applicable for allCommits * Remove commit test utils * Remove commit query * Move allCommits tests No code changes, just moved the files (sperate commit to make it easier to spot changes) * Rename allCommits to commits --- query/graphql/mapper/commitSelect.go | 5 +- query/graphql/parser/commit.go | 6 +- query/graphql/parser/query.go | 4 +- query/graphql/planner/commit.go | 30 +--- query/graphql/planner/dagscan.go | 58 +++----- query/graphql/planner/select.go | 2 +- query/graphql/schema/manager.go | 5 +- query/graphql/schema/types/commits.go | 18 +-- tests/integration/query/all_commits/utils.go | 29 ---- .../query/all_commits/with_cid_test.go | 83 ----------- tests/integration/query/commit/simple_test.go | 43 ------ .../{all_commits => commits}/simple_test.go | 10 +- .../query/{commit => commits}/utils.go | 2 +- .../{commit => commits}/with_cid_test.go | 138 ++++++------------ .../with_dockey_cid_test.go | 14 +- .../with_dockey_count_test.go | 6 +- .../with_dockey_field_test.go | 22 +-- .../with_dockey_limit_offset_test.go | 6 +- .../with_dockey_limit_test.go | 6 +- .../with_dockey_order_limit_offset_test.go | 6 +- .../with_dockey_order_test.go | 18 +-- .../with_dockey_test.go | 22 +-- .../with_dockey_typename_test.go | 6 +- .../with_field_test.go | 14 +- .../integration/query/explain/dagscan_test.go | 122 +--------------- 25 files changed, 154 insertions(+), 521 deletions(-) delete mode 100644 tests/integration/query/all_commits/utils.go delete mode 100644 tests/integration/query/all_commits/with_cid_test.go delete mode 100644 tests/integration/query/commit/simple_test.go rename tests/integration/query/{all_commits => commits}/simple_test.go (92%) rename tests/integration/query/{commit => commits}/utils.go (97%) rename tests/integration/query/{commit => commits}/with_cid_test.go (54%) rename tests/integration/query/{all_commits => commits}/with_dockey_cid_test.go (87%) rename tests/integration/query/{all_commits => commits}/with_dockey_count_test.go (88%) rename tests/integration/query/{all_commits => commits}/with_dockey_field_test.go (76%) rename tests/integration/query/{all_commits => commits}/with_dockey_limit_offset_test.go (86%) rename tests/integration/query/{all_commits => commits}/with_dockey_limit_test.go (87%) rename tests/integration/query/{all_commits => commits}/with_dockey_order_limit_offset_test.go (85%) rename tests/integration/query/{all_commits => commits}/with_dockey_order_test.go (87%) rename tests/integration/query/{all_commits => commits}/with_dockey_test.go (88%) rename tests/integration/query/{all_commits => commits}/with_dockey_typename_test.go (88%) rename tests/integration/query/{all_commits => commits}/with_field_test.go (87%) diff --git a/query/graphql/mapper/commitSelect.go b/query/graphql/mapper/commitSelect.go index a8e1ae8735..fcf5be8c2d 100644 --- a/query/graphql/mapper/commitSelect.go +++ b/query/graphql/mapper/commitSelect.go @@ -18,13 +18,12 @@ type CommitType int const ( NoneCommitType = CommitType(iota) LatestCommits - AllCommits - OneCommit + Commits ) // CommitSelect represents a commit request from a consumer. // -// E.g. allCommits, or latestCommits. +// E.g. commits, or latestCommits. type CommitSelect struct { // The underlying Select, defining the information requested. Select diff --git a/query/graphql/parser/commit.go b/query/graphql/parser/commit.go index 3e7ea93a5d..95cd18a4b4 100644 --- a/query/graphql/parser/commit.go +++ b/query/graphql/parser/commit.go @@ -25,15 +25,13 @@ type CommitType int const ( NoneCommitType = CommitType(iota) LatestCommits - AllCommits - OneCommit + Commits ) var ( commitNameToType = map[string]CommitType{ "latestCommits": LatestCommits, - "allCommits": AllCommits, - "commit": OneCommit, + "commits": Commits, } _ Selection = (*CommitSelect)(nil) diff --git a/query/graphql/parser/query.go b/query/graphql/parser/query.go index c3da4a5a52..f5fe301119 100644 --- a/query/graphql/parser/query.go +++ b/query/graphql/parser/query.go @@ -21,7 +21,7 @@ import ( var dbAPIQueryNames = map[string]bool{ "latestCommits": true, - "allCommits": true, + "commits": true, "commit": true, } @@ -354,7 +354,7 @@ func parseField(root parserTypes.SelectionType, field *ast.Field) *Field { func parseAPIQuery(field *ast.Field) (Selection, error) { switch field.Name.Value { - case "latestCommits", "allCommits", "commit": + case "latestCommits", "commits": return parseCommitSelect(field) default: return nil, errors.New("Unknown query") diff --git a/query/graphql/planner/commit.go b/query/graphql/planner/commit.go index ebd2a12931..dfe06e26c5 100644 --- a/query/graphql/planner/commit.go +++ b/query/graphql/planner/commit.go @@ -107,9 +107,7 @@ func (p *Planner) CommitSelect(parsed *mapper.CommitSelect) (planNode, error) { switch parsed.Type { case mapper.LatestCommits: commit, err = p.commitSelectLatest(parsed) - case mapper.OneCommit: - commit, err = p.commitSelectBlock(parsed) - case mapper.AllCommits: + case mapper.Commits: commit, err = p.commitSelectAll(parsed) default: return nil, errors.New("Invalid CommitSelect type") @@ -130,8 +128,8 @@ func (p *Planner) CommitSelect(parsed *mapper.CommitSelect) (planNode, error) { // commitSelectLatest is a CommitSelect node initalized with a headsetScanNode and a DocKey func (p *Planner) commitSelectLatest(parsed *mapper.CommitSelect) (*commitSelectNode, error) { - dag := p.DAGScan(parsed) headset := p.HeadScan(parsed) + dag := p.DAGScan(parsed, headset) // @todo: Get Collection field ID if !parsed.FieldName.HasValue() { dag.field = core.COMPOSITE_NAMESPACE @@ -143,7 +141,7 @@ func (p *Planner) commitSelectLatest(parsed *mapper.CommitSelect) (*commitSelect key := core.DataStoreKey{}.WithDocKey(parsed.DocKey).WithFieldId(dag.field) headset.key = key } - dag.headset = headset + commit := &commitSelectNode{ p: p, source: dag, @@ -152,29 +150,11 @@ func (p *Planner) commitSelectLatest(parsed *mapper.CommitSelect) (*commitSelect return commit, nil } -// commitSelectBlock is a CommitSelect node initialized without a headsetScanNode, and is expected -// to be given a target CID in the parser.CommitSelect object. It returns a single commit if found. -func (p *Planner) commitSelectBlock(parsed *mapper.CommitSelect) (*commitSelectNode, error) { - dag := p.DAGScan(parsed) - if parsed.Cid != "" { - c, err := cid.Decode(parsed.Cid) - if err != nil { - return nil, err - } - dag.cid = &c - } // @todo: handle error if no CID is given - - return &commitSelectNode{ - p: p, - source: dag, - }, nil -} - // commitSelectAll is a CommitSelect initialized with a headsetScanNode, and will // recursively return all graph commits in order. func (p *Planner) commitSelectAll(parsed *mapper.CommitSelect) (*commitSelectNode, error) { - dag := p.DAGScan(parsed) headset := p.HeadScan(parsed) + dag := p.DAGScan(parsed, headset) if parsed.Cid != "" { c, err := cid.Decode(parsed.Cid) @@ -202,7 +182,7 @@ func (p *Planner) commitSelectAll(parsed *mapper.CommitSelect) (*commitSelectNod headset.key = key } - dag.headset = headset + dag.depthLimit = math.MaxUint32 // infinite depth // dag.key = &key commit := &commitSelectNode{ diff --git a/query/graphql/planner/dagscan.go b/query/graphql/planner/dagscan.go index 7912e45fde..e372e6eac8 100644 --- a/query/graphql/planner/dagscan.go +++ b/query/graphql/planner/dagscan.go @@ -156,12 +156,13 @@ type dagScanNode struct { parsed *mapper.CommitSelect } -func (p *Planner) DAGScan(parsed *mapper.CommitSelect) *dagScanNode { +func (p *Planner) DAGScan(parsed *mapper.CommitSelect, headset *headsetScanNode) *dagScanNode { return &dagScanNode{ p: p, visitedNodes: make(map[string]bool), queuedCids: list.New(), parsed: parsed, + headset: headset, docMapper: docMapper{&parsed.DocumentMapping}, } } @@ -171,17 +172,11 @@ func (n *dagScanNode) Kind() string { } func (n *dagScanNode) Init() error { - if n.headset != nil { - return n.headset.Init() - } - return nil + return n.headset.Init() } func (n *dagScanNode) Start() error { - if n.headset != nil { - return n.headset.Start() - } - return nil + return n.headset.Start() } // Spans needs to parse the given span set. dagScanNode only @@ -194,33 +189,20 @@ func (n *dagScanNode) Spans(spans core.Spans) { return } - // if we have a headset, pass along - // otherwise, try to parse as a CID - if n.headset != nil { - // make sure we have the correct field suffix - headSetSpans := core.Spans{ - HasValue: spans.HasValue, - Value: make([]core.Span, len(spans.Value)), - } - copy(headSetSpans.Value, spans.Value) - span := headSetSpans.Value[0].Start() - if !strings.HasSuffix(span.ToString(), n.field) { - headSetSpans.Value[0] = core.NewSpan(span.WithFieldId(n.field), core.DataStoreKey{}) - } - n.headset.Spans(headSetSpans) - } else { - data := spans.Value[0].Start().ToString() - c, err := cid.Decode(data) - if err == nil { - n.cid = &c - } + // make sure we have the correct field suffix + headSetSpans := core.Spans{ + HasValue: spans.HasValue, + Value: make([]core.Span, len(spans.Value)), + } + copy(headSetSpans.Value, spans.Value) + span := headSetSpans.Value[0].Start() + if !strings.HasSuffix(span.ToString(), n.field) { + headSetSpans.Value[0] = core.NewSpan(span.WithFieldId(n.field), core.DataStoreKey{}) } + n.headset.Spans(headSetSpans) } func (n *dagScanNode) Close() error { - if n.headset == nil { - return nil - } return n.headset.Close() } @@ -275,7 +257,7 @@ func (n *dagScanNode) Next() (bool, error) { } n.queuedCids.Remove(c) n.currentCid = &cid - } else if n.currentCid == nil && n.headset != nil { + } else if n.currentCid == nil { if next, err := n.headset.Next(); !next { return false, err } @@ -292,11 +274,6 @@ func (n *dagScanNode) Next() (bool, error) { return false, nil } n.currentCid = n.cid - } else if n.currentCid == nil { - // add this final elseif case in case another function - // manually sets the CID. Should prob migrate any remote CID - // updates to use the queuedCids. - return false, nil // no queued CIDs and no headset available } // skip already visited CIDs @@ -326,7 +303,7 @@ func (n *dagScanNode) Next() (bool, error) { // based on the specified depth limit. // The default query 'latestCommit' only cares about // the current latest heads, so it has a depth limit - // of 1. The query 'allCommits' doesn't have a depth + // of 1. The query 'commits' doesn't have a depth // limit, so it will continue to traverse the graph // until there are no more links, and no more explored // HEAD paths. @@ -378,8 +355,7 @@ blocks of the MerkleCRDTs. The current available endpoints are: - latestCommit: Given a docid, and optionally a field name, return the latest dag commit - - allCommits: Given a docid, and optionally a field name, return all the dag commits - - oneCommit: Given a cid, return the specific commit + - commits: Given a docid, and optionally a field name, return all the dag commits Additionally, theres a subselection available on the Document query called _version, which returns the current dag commit for the stored CRDT value. diff --git a/query/graphql/planner/select.go b/query/graphql/planner/select.go index f77544d72e..dfe0d6288b 100644 --- a/query/graphql/planner/select.go +++ b/query/graphql/planner/select.go @@ -294,7 +294,7 @@ func (n *selectNode) initFields(parsed *mapper.Select) ([]aggregateNode, error) // a OneCommit subquery, with the supplied parameters. commitSlct.DocKey = parsed.DocKeys.Value[0] // @todo check length commitSlct.Cid = parsed.Cid - commitSlct.Type = mapper.OneCommit + commitSlct.Type = mapper.Commits } else { commitSlct.Type = mapper.LatestCommits } diff --git a/query/graphql/schema/manager.go b/query/graphql/schema/manager.go index cfb573678a..17b51ed597 100644 --- a/query/graphql/schema/manager.go +++ b/query/graphql/schema/manager.go @@ -103,9 +103,8 @@ func defaultQueryType() *gql.Object { }, // database API queries - schemaTypes.QueryAllCommits.Name: schemaTypes.QueryAllCommits, + schemaTypes.QueryCommits.Name: schemaTypes.QueryCommits, schemaTypes.QueryLatestCommits.Name: schemaTypes.QueryLatestCommits, - schemaTypes.QueryCommit.Name: schemaTypes.QueryCommit, }, }) } @@ -170,7 +169,7 @@ func defaultTypes() []gql.Type { schemaTypes.StringOperatorBlock, schemaTypes.NotNullstringOperatorBlock, - schemaTypes.AllCommitsOrderArg, + schemaTypes.CommitsOrderArg, schemaTypes.CommitLinkObject, schemaTypes.CommitObject, schemaTypes.DeltaObject, diff --git a/query/graphql/schema/types/commits.go b/query/graphql/schema/types/commits.go index 43d0fc3935..e6694a4c91 100644 --- a/query/graphql/schema/types/commits.go +++ b/query/graphql/schema/types/commits.go @@ -89,9 +89,9 @@ var ( }, }) - AllCommitsOrderArg = gql.NewInputObject( + CommitsOrderArg = gql.NewInputObject( gql.InputObjectConfig{ - Name: "allCommitsOrderArg", + Name: "commitsOrderArg", Fields: gql.InputObjectConfigFieldMap{ "height": &gql.InputObjectFieldConfig{ Type: OrderingEnum, @@ -103,13 +103,13 @@ var ( }, ) - QueryAllCommits = &gql.Field{ - Name: "allCommits", + QueryCommits = &gql.Field{ + Name: "commits", Type: gql.NewList(CommitObject), Args: gql.FieldConfigArgument{ "dockey": NewArgConfig(gql.ID), "field": NewArgConfig(gql.String), - "order": NewArgConfig(AllCommitsOrderArg), + "order": NewArgConfig(CommitsOrderArg), "cid": NewArgConfig(gql.ID), parserTypes.LimitClause: NewArgConfig(gql.Int), parserTypes.OffsetClause: NewArgConfig(gql.Int), @@ -124,12 +124,4 @@ var ( "field": NewArgConfig(gql.String), }, } - - QueryCommit = &gql.Field{ - Name: "commit", - Type: CommitObject, - Args: gql.FieldConfigArgument{ - "cid": NewArgConfig(gql.NewNonNull(gql.ID)), - }, - } ) diff --git a/tests/integration/query/all_commits/utils.go b/tests/integration/query/all_commits/utils.go deleted file mode 100644 index b3a3590a49..0000000000 --- a/tests/integration/query/all_commits/utils.go +++ /dev/null @@ -1,29 +0,0 @@ -// 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 all_commits - -import ( - "testing" - - testUtils "github.com/sourcenetwork/defradb/tests/integration" -) - -var userCollectionGQLSchema = (` - type users { - Name: String - Age: Int - Verified: Boolean - } -`) - -func executeTestCase(t *testing.T, test testUtils.QueryTestCase) { - testUtils.ExecuteQueryTestCase(t, userCollectionGQLSchema, []string{"users"}, test) -} diff --git a/tests/integration/query/all_commits/with_cid_test.go b/tests/integration/query/all_commits/with_cid_test.go deleted file mode 100644 index c583e75704..0000000000 --- a/tests/integration/query/all_commits/with_cid_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// 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 all_commits - -import ( - "testing" - - testUtils "github.com/sourcenetwork/defradb/tests/integration" -) - -func TestQueryAllCommitsWithCid(t *testing.T) { - test := testUtils.QueryTestCase{ - Description: "Simple all commits query with cid", - Query: `query { - allCommits( - cid: "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Updates: map[int]map[int][]string{ - 0: { - 0: { - `{ - "Age": 22 - }`, - }, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq", - }, - }, - } - - executeTestCase(t, test) -} - -func TestQueryAllCommitsWithCidForFieldCommit(t *testing.T) { - // cid is for a field commit, see TestQueryAllCommitsWithDockeyAndFieldId - test := testUtils.QueryTestCase{ - Description: "Simple all commits query with cid", - Query: `query { - allCommits( - cid: "bafybeidst2mzxhdoh4ayjdjoh4vibo7vwnuoxk3xgyk5mzmep55jklni2a" - ) { - cid - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - Results: []map[string]any{ - { - "cid": "bafybeidst2mzxhdoh4ayjdjoh4vibo7vwnuoxk3xgyk5mzmep55jklni2a", - }, - }, - } - - executeTestCase(t, test) -} diff --git a/tests/integration/query/commit/simple_test.go b/tests/integration/query/commit/simple_test.go deleted file mode 100644 index 05b6be4c74..0000000000 --- a/tests/integration/query/commit/simple_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// 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 commit - -import ( - "testing" - - testUtils "github.com/sourcenetwork/defradb/tests/integration" -) - -// This test is for documentation reasons only. This is not -// desired behaviour (should return all commits). -func TestQueryOneCommit(t *testing.T) { - test := testUtils.QueryTestCase{ - Description: "query for a single block by CID", - Query: `query { - commit { - cid - height - delta - } - }`, - Docs: map[int][]string{ - 0: { - `{ - "Name": "John", - "Age": 21 - }`, - }, - }, - ExpectedError: "Field \"commit\" argument \"cid\" of type \"ID!\" is required but not provided.", - } - - executeTestCase(t, test) -} diff --git a/tests/integration/query/all_commits/simple_test.go b/tests/integration/query/commits/simple_test.go similarity index 92% rename from tests/integration/query/all_commits/simple_test.go rename to tests/integration/query/commits/simple_test.go index 702257d8c2..359c96c6f5 100644 --- a/tests/integration/query/all_commits/simple_test.go +++ b/tests/integration/query/commits/simple_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommits(t *testing.T) { +func TestQueryCommits(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query", Query: `query { - allCommits { + commits { cid } }`, @@ -48,11 +48,11 @@ func TestQueryAllCommits(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsMultipleDocs(t *testing.T) { +func TestQueryCommitsMultipleDocs(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query, multiple docs", Query: `query { - allCommits { + commits { cid } }`, diff --git a/tests/integration/query/commit/utils.go b/tests/integration/query/commits/utils.go similarity index 97% rename from tests/integration/query/commit/utils.go rename to tests/integration/query/commits/utils.go index 298340511b..950639529d 100644 --- a/tests/integration/query/commit/utils.go +++ b/tests/integration/query/commits/utils.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package commit +package commits import ( "testing" diff --git a/tests/integration/query/commit/with_cid_test.go b/tests/integration/query/commits/with_cid_test.go similarity index 54% rename from tests/integration/query/commit/with_cid_test.go rename to tests/integration/query/commits/with_cid_test.go index 2eb2d0fa56..0ac6b53815 100644 --- a/tests/integration/query/commit/with_cid_test.go +++ b/tests/integration/query/commits/with_cid_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package commit +package commits import ( "testing" @@ -16,16 +16,14 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -// This test is for documentation reasons only. This is not -// desired behaviour (error message could be better, or empty result). -func TestQueryOneCommitWithInvalidCid(t *testing.T) { +func TestQueryCommitsWithCid(t *testing.T) { test := testUtils.QueryTestCase{ - Description: "query for a single block by invalid CID", + Description: "Simple all commits query with cid", Query: `query { - commit(cid: "fhbnjfahfhfhanfhga") { + commits( + cid: "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq" + ) { cid - height - delta } }`, Docs: map[int][]string{ @@ -36,22 +34,34 @@ func TestQueryOneCommitWithInvalidCid(t *testing.T) { }`, }, }, - ExpectedError: "encoding/hex: invalid byte:", + Updates: map[int]map[int][]string{ + 0: { + 0: { + `{ + "Age": 22 + }`, + }, + }, + }, + Results: []map[string]any{ + { + "cid": "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq", + }, + }, } executeTestCase(t, test) } -// This test is for documentation reasons only. This is not -// desired behaviour (error message could be better, or empty result). -func TestQueryOneCommitWithInvalidShortCid(t *testing.T) { +func TestQueryCommitsWithCidForFieldCommit(t *testing.T) { + // cid is for a field commit, see TestQueryCommitsWithDockeyAndFieldId test := testUtils.QueryTestCase{ - Description: "query for a single block by invalid, short CID", + Description: "Simple all commits query with cid", Query: `query { - commit(cid: "bafybeidfhbnjfahfhfhanfhga") { + commits( + cid: "bafybeidst2mzxhdoh4ayjdjoh4vibo7vwnuoxk3xgyk5mzmep55jklni2a" + ) { cid - height - delta } }`, Docs: map[int][]string{ @@ -62,19 +72,23 @@ func TestQueryOneCommitWithInvalidShortCid(t *testing.T) { }`, }, }, - ExpectedError: "length greater than remaining number of bytes in buffer", + Results: []map[string]any{ + { + "cid": "bafybeidst2mzxhdoh4ayjdjoh4vibo7vwnuoxk3xgyk5mzmep55jklni2a", + }, + }, } executeTestCase(t, test) } // This test is for documentation reasons only. This is not -// desired behaviour (should be empty result). -func TestQueryOneCommitWithUnknownCid(t *testing.T) { +// desired behaviour (error message could be better, or empty result). +func TestQueryCommitsWithInvalidCid(t *testing.T) { test := testUtils.QueryTestCase{ - Description: "query for a single block by unknown CID", + Description: "query for a single block by invalid CID", Query: `query { - commit(cid: "bafybeid57gpbwi4i6bg7g35hhhhhhhhhhhhhhhhhhhhhhhdoesnotexist") { + commits(cid: "fhbnjfahfhfhanfhga") { cid height delta @@ -88,17 +102,19 @@ func TestQueryOneCommitWithUnknownCid(t *testing.T) { }`, }, }, - ExpectedError: "ipld: could not find", + ExpectedError: "encoding/hex: invalid byte:", } executeTestCase(t, test) } -func TestQueryOneCommitWithCid(t *testing.T) { +// This test is for documentation reasons only. This is not +// desired behaviour (error message could be better, or empty result). +func TestQueryCommitsWithInvalidShortCid(t *testing.T) { test := testUtils.QueryTestCase{ - Description: "query for a single block by CID", + Description: "query for a single block by invalid, short CID", Query: `query { - commit(cid: "bafybeid57gpbwi4i6bg7g357vwwyzsmr4bjo22rmhoxrwqvdxlqxcgaqvu") { + commits(cid: "bafybeidfhbnjfahfhfhanfhga") { cid height delta @@ -112,48 +128,20 @@ func TestQueryOneCommitWithCid(t *testing.T) { }`, }, }, - Results: []map[string]any{ - { - "cid": "bafybeid57gpbwi4i6bg7g357vwwyzsmr4bjo22rmhoxrwqvdxlqxcgaqvu", - "height": int64(1), - // cbor encoded delta - "delta": []uint8{ - 0xa2, - 0x63, - 0x41, - 0x67, - 0x65, - 0x15, - 0x64, - 0x4e, - 0x61, - 0x6d, - 0x65, - 0x64, - 0x4a, - 0x6f, - 0x68, - 0x6e, - }, - }, - }, + ExpectedError: "length greater than remaining number of bytes in buffer", } executeTestCase(t, test) } -func TestQueryOneCommitWithCidAndLinks(t *testing.T) { +func TestQueryCommitsWithUnknownCid(t *testing.T) { test := testUtils.QueryTestCase{ - Description: "query for a single block by CID, with links", + Description: "query for a single block by unknown CID", Query: `query { - commit(cid: "bafybeid57gpbwi4i6bg7g357vwwyzsmr4bjo22rmhoxrwqvdxlqxcgaqvu") { + commits(cid: "bafybeid57gpbwi4i6bg7g35hhhhhhhhhhhhhhhhhhhhhhhdoesnotexist") { cid height delta - links { - cid - name - } } }`, Docs: map[int][]string{ @@ -164,41 +152,7 @@ func TestQueryOneCommitWithCidAndLinks(t *testing.T) { }`, }, }, - Results: []map[string]any{ - { - "cid": "bafybeid57gpbwi4i6bg7g357vwwyzsmr4bjo22rmhoxrwqvdxlqxcgaqvu", - "height": int64(1), - // cbor encoded delta - "delta": []uint8{ - 0xa2, - 0x63, - 0x41, - 0x67, - 0x65, - 0x15, - 0x64, - 0x4e, - 0x61, - 0x6d, - 0x65, - 0x64, - 0x4a, - 0x6f, - 0x68, - 0x6e, - }, - "links": []map[string]any{ - { - "cid": "bafybeidst2mzxhdoh4ayjdjoh4vibo7vwnuoxk3xgyk5mzmep55jklni2a", - "name": "Age", - }, - { - "cid": "bafybeihhypcsqt7blkrqtcmpl43eo3yunrog5pchox5naji6hisdme4swm", - "name": "Name", - }, - }, - }, - }, + Results: []map[string]any{}, } executeTestCase(t, test) diff --git a/tests/integration/query/all_commits/with_dockey_cid_test.go b/tests/integration/query/commits/with_dockey_cid_test.go similarity index 87% rename from tests/integration/query/all_commits/with_dockey_cid_test.go rename to tests/integration/query/commits/with_dockey_cid_test.go index bd779aed48..10f8a6850e 100644 --- a/tests/integration/query/all_commits/with_dockey_cid_test.go +++ b/tests/integration/query/commits/with_dockey_cid_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndCidForDifferentDoc(t *testing.T) { +func TestQueryCommitsWithDockeyAndCidForDifferentDoc(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and cid", Query: `query { - allCommits( + commits( dockey: "bae-not-this-doc", cid: "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq" ) { @@ -41,11 +41,11 @@ func TestQueryAllCommitsWithDockeyAndCidForDifferentDoc(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndCidForDifferentDocWithUpdate(t *testing.T) { +func TestQueryCommitsWithDockeyAndCidForDifferentDocWithUpdate(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and cid", Query: `query { - allCommits( + commits( dockey: "bae-not-this-doc", cid: "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq" ) { @@ -75,11 +75,11 @@ func TestQueryAllCommitsWithDockeyAndCidForDifferentDocWithUpdate(t *testing.T) executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndCid(t *testing.T) { +func TestQueryCommitsWithDockeyAndCid(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and cid", Query: `query { - allCommits( + commits( dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", cid: "bafybeibrbfg35mwggcj4vnskak4qn45hp7fy5a4zp2n34sbq5vt5utr6pq" ) { diff --git a/tests/integration/query/all_commits/with_dockey_count_test.go b/tests/integration/query/commits/with_dockey_count_test.go similarity index 88% rename from tests/integration/query/all_commits/with_dockey_count_test.go rename to tests/integration/query/commits/with_dockey_count_test.go index a3676d0193..e931943b5a 100644 --- a/tests/integration/query/all_commits/with_dockey_count_test.go +++ b/tests/integration/query/commits/with_dockey_count_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndLinkCount(t *testing.T) { +func TestQueryCommitsWithDockeyAndLinkCount(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple latest commits query with dockey and link count", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid _count(field: links) } diff --git a/tests/integration/query/all_commits/with_dockey_field_test.go b/tests/integration/query/commits/with_dockey_field_test.go similarity index 76% rename from tests/integration/query/all_commits/with_dockey_field_test.go rename to tests/integration/query/commits/with_dockey_field_test.go index 39642be549..e702209162 100644 --- a/tests/integration/query/all_commits/with_dockey_field_test.go +++ b/tests/integration/query/commits/with_dockey_field_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndUnknownField(t *testing.T) { +func TestQueryCommitsWithDockeyAndUnknownField(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and unknown field", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "not a field") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "not a field") { cid } }`, @@ -38,11 +38,11 @@ func TestQueryAllCommitsWithDockeyAndUnknownField(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndUnknownFieldId(t *testing.T) { +func TestQueryCommitsWithDockeyAndUnknownFieldId(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and unknown field id", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "999999") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "999999") { cid } }`, @@ -62,11 +62,11 @@ func TestQueryAllCommitsWithDockeyAndUnknownFieldId(t *testing.T) { // This test is for documentation reasons only. This is not // desired behaviour (should return all commits for dockey-field). -func TestQueryAllCommitsWithDockeyAndField(t *testing.T) { +func TestQueryCommitsWithDockeyAndField(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and field", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "Age") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "Age") { cid } }`, @@ -86,11 +86,11 @@ func TestQueryAllCommitsWithDockeyAndField(t *testing.T) { // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). -func TestQueryAllCommitsWithDockeyAndFieldId(t *testing.T) { +func TestQueryCommitsWithDockeyAndFieldId(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and field id", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "1") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "1") { cid } }`, @@ -114,11 +114,11 @@ func TestQueryAllCommitsWithDockeyAndFieldId(t *testing.T) { // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). -func TestQueryAllCommitsWithDockeyAndCompositeFieldId(t *testing.T) { +func TestQueryCommitsWithDockeyAndCompositeFieldId(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and field id", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "C") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", field: "C") { cid } }`, diff --git a/tests/integration/query/all_commits/with_dockey_limit_offset_test.go b/tests/integration/query/commits/with_dockey_limit_offset_test.go similarity index 86% rename from tests/integration/query/all_commits/with_dockey_limit_offset_test.go rename to tests/integration/query/commits/with_dockey_limit_offset_test.go index 9ae8099a28..8d52e12ab1 100644 --- a/tests/integration/query/all_commits/with_dockey_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_limit_offset_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndLimitAndOffset(t *testing.T) { +func TestQueryCommitsWithDockeyAndLimitAndOffset(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, limit and offset", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2, offset: 1) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2, offset: 1) { cid } }`, diff --git a/tests/integration/query/all_commits/with_dockey_limit_test.go b/tests/integration/query/commits/with_dockey_limit_test.go similarity index 87% rename from tests/integration/query/all_commits/with_dockey_limit_test.go rename to tests/integration/query/commits/with_dockey_limit_test.go index ad6a2c60a3..4b1524f953 100644 --- a/tests/integration/query/all_commits/with_dockey_limit_test.go +++ b/tests/integration/query/commits/with_dockey_limit_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndLimit(t *testing.T) { +func TestQueryCommitsWithDockeyAndLimit(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and limit", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", limit: 2) { cid } }`, diff --git a/tests/integration/query/all_commits/with_dockey_order_limit_offset_test.go b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go similarity index 85% rename from tests/integration/query/all_commits/with_dockey_order_limit_offset_test.go rename to tests/integration/query/commits/with_dockey_order_limit_offset_test.go index c1cc4f1fd9..62733b081d 100644 --- a/tests/integration/query/all_commits/with_dockey_order_limit_offset_test.go +++ b/tests/integration/query/commits/with_dockey_order_limit_offset_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { +func TestQueryCommitsWithDockeyAndOrderAndLimitAndOffset(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, order, limit and offset", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}, limit: 2, offset: 4) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}, limit: 2, offset: 4) { cid height } diff --git a/tests/integration/query/all_commits/with_dockey_order_test.go b/tests/integration/query/commits/with_dockey_order_test.go similarity index 87% rename from tests/integration/query/all_commits/with_dockey_order_test.go rename to tests/integration/query/commits/with_dockey_order_test.go index 2aa98d4488..ed2d7c5ba4 100644 --- a/tests/integration/query/all_commits/with_dockey_order_test.go +++ b/tests/integration/query/commits/with_dockey_order_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { +func TestQueryCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, order height desc", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: DESC}) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: DESC}) { cid height } @@ -69,11 +69,11 @@ func TestQueryAllCommitsWithDockeyAndOrderHeightDesc(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { +func TestQueryCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, order height asc", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {height: ASC}) { cid height } @@ -122,11 +122,11 @@ func TestQueryAllCommitsWithDockeyAndOrderHeightAsc(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndOrderCidDesc(t *testing.T) { +func TestQueryCommitsWithDockeyAndOrderCidDesc(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, order cid desc", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: DESC}) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: DESC}) { cid height } @@ -175,11 +175,11 @@ func TestQueryAllCommitsWithDockeyAndOrderCidDesc(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndOrderCidAsc(t *testing.T) { +func TestQueryCommitsWithDockeyAndOrderCidAsc(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, order cid asc", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: ASC}) { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f", order: {cid: ASC}) { cid height } diff --git a/tests/integration/query/all_commits/with_dockey_test.go b/tests/integration/query/commits/with_dockey_test.go similarity index 88% rename from tests/integration/query/all_commits/with_dockey_test.go rename to tests/integration/query/commits/with_dockey_test.go index c03ea5ce25..931d41a532 100644 --- a/tests/integration/query/all_commits/with_dockey_test.go +++ b/tests/integration/query/commits/with_dockey_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithUnknownDockey(t *testing.T) { +func TestQueryCommitsWithUnknownDockey(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with unknown dockey", Query: `query { - allCommits(dockey: "unknown dockey") { + commits(dockey: "unknown dockey") { cid } }`, @@ -38,11 +38,11 @@ func TestQueryAllCommitsWithUnknownDockey(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockey(t *testing.T) { +func TestQueryCommitsWithDockey(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid } }`, @@ -70,11 +70,11 @@ func TestQueryAllCommitsWithDockey(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndLinks(t *testing.T) { +func TestQueryCommitsWithDockeyAndLinks(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, with links", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid links { cid @@ -118,11 +118,11 @@ func TestQueryAllCommitsWithDockeyAndLinks(t *testing.T) { executeTestCase(t, test) } -func TestQueryAllCommitsWithDockeyAndUpdate(t *testing.T) { +func TestQueryCommitsWithDockeyAndUpdate(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, multiple results", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid height } @@ -174,11 +174,11 @@ func TestQueryAllCommitsWithDockeyAndUpdate(t *testing.T) { // This test is for documentation reasons only. This is not // desired behaviour (first results includes link._head, second // includes link._Name). -func TestQueryAllCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { +func TestQueryCommitsWithDockeyAndUpdateAndLinks(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey, multiple results and links", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid links { cid diff --git a/tests/integration/query/all_commits/with_dockey_typename_test.go b/tests/integration/query/commits/with_dockey_typename_test.go similarity index 88% rename from tests/integration/query/all_commits/with_dockey_typename_test.go rename to tests/integration/query/commits/with_dockey_typename_test.go index cb844fb62c..5d3328dc2d 100644 --- a/tests/integration/query/all_commits/with_dockey_typename_test.go +++ b/tests/integration/query/commits/with_dockey_typename_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -16,11 +16,11 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestQueryAllCommitsWithDockeyWithTypeName(t *testing.T) { +func TestQueryCommitsWithDockeyWithTypeName(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and typename", Query: `query { - allCommits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { + commits(dockey: "bae-52b9170d-b77a-5887-b877-cbdbb99b009f") { cid __typename } diff --git a/tests/integration/query/all_commits/with_field_test.go b/tests/integration/query/commits/with_field_test.go similarity index 87% rename from tests/integration/query/all_commits/with_field_test.go rename to tests/integration/query/commits/with_field_test.go index 57ef3eb13f..f096db10d0 100644 --- a/tests/integration/query/all_commits/with_field_test.go +++ b/tests/integration/query/commits/with_field_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package all_commits +package commits import ( "testing" @@ -18,11 +18,11 @@ import ( // This test is for documentation reasons only. This is not // desired behaviour (should return all commits for dockey-field). -func TestQueryAllCommitsWithField(t *testing.T) { +func TestQueryCommitsWithField(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with field", Query: `query { - allCommits (field: "Age") { + commits (field: "Age") { cid } }`, @@ -42,11 +42,11 @@ func TestQueryAllCommitsWithField(t *testing.T) { // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). -func TestQueryAllCommitsWithFieldId(t *testing.T) { +func TestQueryCommitsWithFieldId(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with field id", Query: `query { - allCommits (field: "1") { + commits (field: "1") { cid } }`, @@ -70,11 +70,11 @@ func TestQueryAllCommitsWithFieldId(t *testing.T) { // This test is for documentation reasons only. This is not // desired behaviour (users should not be specifying field ids). -func TestQueryAllCommitsWithCompositeFieldId(t *testing.T) { +func TestQueryCommitsWithCompositeFieldId(t *testing.T) { test := testUtils.QueryTestCase{ Description: "Simple all commits query with dockey and field id", Query: `query { - allCommits(field: "C") { + commits(field: "C") { cid } }`, diff --git a/tests/integration/query/explain/dagscan_test.go b/tests/integration/query/explain/dagscan_test.go index 45278f967e..dd0e96fd94 100644 --- a/tests/integration/query/explain/dagscan_test.go +++ b/tests/integration/query/explain/dagscan_test.go @@ -16,13 +16,13 @@ import ( testUtils "github.com/sourcenetwork/defradb/tests/integration" ) -func TestExplainAllCommitsDagScan(t *testing.T) { +func TestExplainCommitsDagScan(t *testing.T) { test := testUtils.QueryTestCase{ - Description: "Explain allCommits query.", + Description: "Explain commits query.", Query: `query @explain { - allCommits (dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3", field: "1") { + commits (dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3", field: "1") { links { cid } @@ -75,13 +75,13 @@ func TestExplainAllCommitsDagScan(t *testing.T) { executeTestCase(t, test) } -func TestExplainAllCommitsDagScanWithoutField(t *testing.T) { +func TestExplainCommitsDagScanWithoutField(t *testing.T) { test := testUtils.QueryTestCase{ - Description: "Explain allCommits query with only dockey (no field).", + Description: "Explain commits query with only dockey (no field).", Query: `query @explain { - allCommits (dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3") { + commits (dockey: "bae-41598f0c-19bc-5da6-813b-e80f14a10df3") { links { cid } @@ -293,113 +293,3 @@ func TestExplainLatestCommitsDagScanWithoutAnyArguments_Failure(t *testing.T) { executeTestCase(t, test) } - -func TestExplainOneCommitDagScan(t *testing.T) { - test := testUtils.QueryTestCase{ - - Description: "Explain commit query.", - - Query: `query @explain { - commit(cid: "bafybeieys3v7timp2c2k4krqeojaa7ecqaairvtf7lo7jah24gtuicpk3u") { - cid - height - delta - } - }`, - - Docs: map[int][]string{ - //authors - 2: { - // bae-41598f0c-19bc-5da6-813b-e80f14a10df3 - `{ - "name": "John Grisham", - "age": 65, - "verified": true - }`, - // bae-b769708d-f552-5c3d-a402-ccfd7ac7fb04 - `{ - "name": "Cornelia Funke", - "age": 62, - "verified": false - }`, - }, - }, - - Results: []dataMap{ - { - "explain": dataMap{ - "selectTopNode": dataMap{ - "selectNode": dataMap{ - "filter": nil, - "commitSelectNode": dataMap{ - "dagScanNode": dataMap{ - "cid": []uint8{ - 0x01, - 0x70, - 0x12, - 0x20, - 0x98, - 0x96, - 0xeb, - 0xf9, - 0xa1, - 0x8f, - 0xd0, - 0xb4, - 0xae, - 0x2a, - 0x30, - 0x23, - 0x92, - 0x00, - 0x7c, - 0x82, - 0x80, - 0x00, - 0x88, - 0xd6, - 0x65, - 0xfa, - 0xdd, - 0xf4, - 0x80, - 0xfa, - 0xe1, - 0xa7, - 0x44, - 0x09, - 0xea, - 0xdd, - }, - "field": nil, - "spans": []dataMap{}, - }, - }, - }, - }, - }, - }, - }, - } - - executeTestCase(t, test) -} - -func TestExplainOneCommitDagScanWithNoArguments(t *testing.T) { - test := testUtils.QueryTestCase{ - - Description: "Explain commit query with no arguments.", - - Query: `query @explain { - commit { - cid - height - delta - } - }`, - - ExpectedError: "Field \"commit\" argument \"cid\" of type \"ID!\" is required but not provided.", - } - - executeTestCase(t, test) -}