Skip to content

Commit

Permalink
PR FIXUP - Add Explain test stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Feb 15, 2024
1 parent c5216c6 commit aa21960
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/integration/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
"updateNode": {},
"valuesNode": {},
"viewNode": {},
"lensNode": {},
}
)

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

"github.com/lens-vm/lens/host-go/config/model"

Check failure on line 16 in tests/integration/explain/debug/with_view_transform_test.go

View workflow job for this annotation

GitHub Actions / Lint GoLang job

File is not `goimports`-ed with -local github.com/sourcenetwork/defradb (goimports)
testUtils "github.com/sourcenetwork/defradb/tests/integration"
"github.com/sourcenetwork/defradb/tests/lenses"
"github.com/sourcenetwork/immutable"
)

var transformViewPattern = dataMap{
"explain": dataMap{
"selectTopNode": dataMap{
"selectNode": dataMap{
"viewNode": dataMap{
"lensNode": dataMap{
"selectTopNode": dataMap{
"selectNode": dataMap{
"scanNode": dataMap{},
},
},
},
},
},
},
},
}

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

Description: "Explain (debug) request with view with transform",
Actions: []any{
testUtils.SchemaUpdate{
Schema: `
type User {
name: String
}
`,
},
testUtils.CreateView{
Query: `
User {
name
}
`,
SDL: `
type UserView {
fullName: String
}
`,
Transform: immutable.Some(model.Lens{
Lenses: []model.LensModule{
{
Path: lenses.CopyModulePath,
Arguments: map[string]any{
"src": "name",
"dst": "fullName",
},
},
},
}),
},
testUtils.ExplainRequest{
Request: `query @explain(type: debug) {
UserView {
fullName
}
}`,
ExpectedPatterns: []dataMap{transformViewPattern},
},
},
}

testUtils.ExecuteTestCase(t, test)
}

0 comments on commit aa21960

Please sign in to comment.