diff --git a/tests/integration/index/simple_test.go b/tests/integration/index/simple_test.go deleted file mode 100644 index 78219813aa..0000000000 --- a/tests/integration/index/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 index - -import ( - "testing" - - testUtils "github.com/sourcenetwork/defradb/tests/integration" -) - -func TestSchemaWithIndexOnTheOnlyField(t *testing.T) { - test := testUtils.TestCase{ - Actions: []any{ - testUtils.SchemaUpdate{ - Schema: ` - type users { - name: String @index - } - `, - }, - createUserDocs(), - testUtils.Request{ - Request: ` - query @explain(type: execute) { - users(filter: {name: {_eq: "Shahzad"}}) { - name - } - }`, - Asserter: newExplainAsserter(2, 8, 1), - }, - }, - } - - testUtils.ExecuteTestCase(t, []string{"users"}, test) -} diff --git a/tests/integration/index/utils.go b/tests/integration/index/utils.go deleted file mode 100644 index ca4dc3981a..0000000000 --- a/tests/integration/index/utils.go +++ /dev/null @@ -1,103 +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 index - -import ( - "testing" - - testUtils "github.com/sourcenetwork/defradb/tests/integration" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -type dataMap = map[string]any - -type explainResultAsserter struct { - iterations int - docFetches int - filterMatches int -} - -func (a explainResultAsserter) Assert(t *testing.T, result []dataMap) { - require.Len(t, result, 1, "Expected one result, got %d", len(result)) - explainNode, ok := result[0]["explain"].(dataMap) - require.True(t, ok, "Expected explain") - assert.Equal(t, explainNode["executionSuccess"], true) - assert.Equal(t, explainNode["sizeOfResult"], 1) - assert.Equal(t, explainNode["planExecutions"], uint64(2)) - selectTopNode, ok := explainNode["selectTopNode"].(dataMap) - require.True(t, ok, "Expected selectTopNode") - selectNode, ok := selectTopNode["selectNode"].(dataMap) - require.True(t, ok, "Expected selectNode") - scanNode, ok := selectNode["scanNode"].(dataMap) - require.True(t, ok, "Expected scanNode") - assert.Equal(t, scanNode["iterations"], uint64(a.iterations), - "Expected %d iterations, got %d", a.iterations, scanNode["iterations"]) - assert.Equal(t, scanNode["docFetches"], uint64(a.docFetches), - "Expected %d docFetches, got %d", a.docFetches, scanNode["docFetches"]) - assert.Equal(t, scanNode["filterMatches"], uint64(a.filterMatches), - "Expected %d filterMatches, got %d", a.filterMatches, scanNode["filterMatches"]) -} - -func newExplainAsserter(iterations, docFetched, filterMatcher int) *explainResultAsserter { - return &explainResultAsserter{ - iterations: iterations, - docFetches: docFetched, - filterMatches: filterMatcher, - } -} - -func createUserDocs() []testUtils.CreateDoc { - return []testUtils.CreateDoc{ - { - CollectionID: 0, - Doc: `{ - "name": "John" - }`, - }, - { - CollectionID: 0, - Doc: `{ - "name": "Islam" - }`, - }, - { - CollectionID: 0, - Doc: `{ - "name": "Andy" - }`, - }, - { - CollectionID: 0, - Doc: `{ - "name": "Shahzad" - }`, - }, - { - CollectionID: 0, - Doc: `{ - "name": "Fred" - }`, - }, - { - CollectionID: 0, - Doc: `{ - "name": "Orpheus" - }`, - }, - { - CollectionID: 0, - Doc: `{ - "name": "Addo" - }`, - }, - } -}