-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pr: test - Add a temporary old and new test file to make understanding
the new explain test vs old one easier (these will be removed once all tests are converted to this setup and feedback on draft is received).
- Loading branch information
1 parent
da51270
commit d55babf
Showing
1 changed file
with
214 additions
and
0 deletions.
There are no files selected for viewing
214 changes: 214 additions & 0 deletions
214
tests/integration/explain/simple/old_and_new_example_test.go
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,214 @@ | ||
// 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 test_explain_simple | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
explainUtils "github.com/sourcenetwork/defradb/tests/integration/explain" | ||
) | ||
|
||
func TestExplainNew(t *testing.T) { | ||
test := explainUtils.ExplainRequestTestCase{ | ||
|
||
Description: "NEW Explain simple update mutation with boolean equals filter, multiple rows", | ||
|
||
Request: `mutation @explain { | ||
update_author( | ||
filter: { | ||
verified: { | ||
_eq: true | ||
} | ||
}, | ||
data: "{\"age\": 59}" | ||
) { | ||
_key | ||
name | ||
age | ||
} | ||
}`, | ||
|
||
Docs: map[int][]string{ | ||
2: { | ||
// bae-bfbfc89c-0d63-5ea4-81a3-3ebd295be67f | ||
`{ | ||
"name": "Lone", | ||
"age": 26, | ||
"verified": false | ||
}`, | ||
// "bae-079d0bd8-4b1b-5f5f-bd95-4d915c277f9d" | ||
`{ | ||
"name": "Shahzad Lone", | ||
"age": 27, | ||
"verified": true | ||
}`, | ||
}, | ||
}, | ||
|
||
ExpectedFullGraph: []dataMap{ | ||
{ | ||
"explain": dataMap{ | ||
"updateNode": dataMap{ | ||
"data": dataMap{ | ||
"age": float64(59), | ||
}, | ||
"filter": dataMap{ | ||
"verified": dataMap{ | ||
"_eq": true, | ||
}, | ||
}, | ||
"ids": []string(nil), | ||
"selectTopNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"filter": nil, | ||
"scanNode": dataMap{ | ||
"collectionID": "3", | ||
"collectionName": "author", | ||
"filter": dataMap{ | ||
"verified": dataMap{ | ||
"_eq": true, | ||
}, | ||
}, | ||
"spans": []dataMap{ | ||
{ | ||
"end": "/4", | ||
"start": "/3", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
ExpectedPatterns: []dataMap{ | ||
{ | ||
"explain": dataMap{ | ||
"updateNode": dataMap{ | ||
"selectTopNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"scanNode": dataMap{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
ExpectedTargets: []explainUtils.PlanNodeTargetCase{ | ||
{ | ||
TargetNodeName: "updateNode", | ||
ExpectedAttributes: dataMap{ | ||
"data": dataMap{ | ||
"age": float64(59), | ||
}, | ||
"filter": dataMap{ | ||
"verified": dataMap{ | ||
"_eq": true, | ||
}, | ||
}, | ||
"ids": []string(nil), | ||
}, | ||
}, | ||
|
||
{ | ||
TargetNodeName: "selectNode", | ||
ExpectedAttributes: dataMap{ | ||
"filter": nil, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
executeExplainTestCase(t, test) | ||
} | ||
|
||
func TestExplainOld(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
|
||
Description: "Explain simple update mutation with boolean equals filter, multiple rows", | ||
|
||
Query: `mutation @explain { | ||
update_author( | ||
filter: { | ||
verified: { | ||
_eq: true | ||
} | ||
}, | ||
data: "{\"age\": 59}" | ||
) { | ||
_key | ||
name | ||
age | ||
} | ||
}`, | ||
|
||
Docs: map[int][]string{ | ||
2: { | ||
// bae-bfbfc89c-0d63-5ea4-81a3-3ebd295be67f | ||
`{ | ||
"name": "Lone", | ||
"age": 26, | ||
"verified": false | ||
}`, | ||
// "bae-079d0bd8-4b1b-5f5f-bd95-4d915c277f9d" | ||
`{ | ||
"name": "Shahzad Lone", | ||
"age": 27, | ||
"verified": true | ||
}`, | ||
}, | ||
}, | ||
|
||
Results: []dataMap{ | ||
{ | ||
"explain": dataMap{ | ||
"updateNode": dataMap{ | ||
"data": dataMap{ | ||
"age": float64(59), | ||
}, | ||
"filter": dataMap{ | ||
"verified": dataMap{ | ||
"_eq": true, | ||
}, | ||
}, | ||
"ids": []string(nil), | ||
"selectTopNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"filter": nil, | ||
"scanNode": dataMap{ | ||
"collectionID": "3", | ||
"collectionName": "author", | ||
"filter": dataMap{ | ||
"verified": dataMap{ | ||
"_eq": true, | ||
}, | ||
}, | ||
"spans": []dataMap{ | ||
{ | ||
"end": "/4", | ||
"start": "/3", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
executeTestCase(t, test) | ||
} |