Skip to content

Commit

Permalink
PR: Fix debug explain test-framework and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Feb 20, 2025
1 parent 9693071 commit e3c31e5
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 27 deletions.
55 changes: 28 additions & 27 deletions tests/integration/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,34 @@ var (
"subType": {},

// These are all valid nodes.
"averageNode": {},
"countNode": {},
"createNode": {},
"dagScanNode": {},
"deleteNode": {},
"groupNode": {},
"limitNode": {},
"maxNode": {},
"minNode": {},
"multiScanNode": {},
"orderNode": {},
"parallelNode": {},
"pipeNode": {},
"scanNode": {},
"selectNode": {},
"selectTopNode": {},
"sumNode": {},
"topLevelNode": {},
"typeIndexJoin": {},
"typeJoinMany": {},
"typeJoinOne": {},
"updateNode": {},
"upsertNode": {},
"valuesNode": {},
"viewNode": {},
"lensNode": {},
"operationNode": {},
"averageNode": {},
"countNode": {},
"createNode": {},
"dagScanNode": {},
"deleteNode": {},
"groupNode": {},
"limitNode": {},
"maxNode": {},
"minNode": {},
"multiScanNode": {},
"orderNode": {},
"parallelNode": {},
"pipeNode": {},
"scanNode": {},
"selectNode": {},
"selectTopNode": {},
"sumNode": {},
"topLevelNode": {},
"typeIndexJoin": {},
"typeJoinMany": {},
"typeJoinOne": {},
"updateNode": {},
"upsertNode": {},
"valuesNode": {},
"viewNode": {},
"lensNode": {},
"operationNode": {},
"similarityNode": {},
}
)

Expand Down
70 changes: 70 additions & 0 deletions tests/integration/explain/debug/with_similarity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2025 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 test_explain_debug

import (
"testing"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
explainUtils "github.com/sourcenetwork/defradb/tests/integration/explain"
)

var similarityPattern = dataMap{
"explain": dataMap{
"operationNode": []dataMap{
{
"selectTopNode": dataMap{
"similarityNode": dataMap{
"selectNode": dataMap{
"scanNode": dataMap{},
},
},
},
},
},
},
}

func TestDebugExplainRequestWith_WithSimilarity(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (debug) request with similarity.",

Actions: []any{
testUtils.SchemaUpdate{
Schema: `type User {
name: String
pointsList: [Float64!]
}`,
},
testUtils.CreateDoc{
DocMap: map[string]any{
"name": "John",
"pointsList": []float64{2, 4, 1},
},
},

testUtils.ExplainRequest{

Request: `query @explain(type: debug) {
User {
name
_similarity(pointsList: {vector: [1, 2, 0]})
}
}`,

ExpectedFullGraph: similarityPattern,
},
},
}

explainUtils.ExecuteTestCase(t, test)
}

0 comments on commit e3c31e5

Please sign in to comment.