forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR: Fix debug explain test-framework and add tests
- Loading branch information
1 parent
9693071
commit e3c31e5
Showing
2 changed files
with
98 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |