-
Notifications
You must be signed in to change notification settings - Fork 8
chore: Testing OpenCypher Components in BDD format BED-9180 #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ykaiboussiSO
wants to merge
11
commits into
main
Choose a base branch
from
BED-9180
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
984581b
chore: Testing OpenCypher Components in BDD format
ykaiboussiSO 5ae29ae
Update Makefile
ykaiboussiSO 3079918
Update steps_test.go
ykaiboussiSO a73bad5
Create context_test.go
ykaiboussiSO 6e060dc
update docs
ykaiboussiSO 26b655c
Increase test coverage
ykaiboussiSO dbe7839
format strings
ykaiboussiSO 9ac68ff
- Update jobs permissions
ykaiboussiSO d3d1703
update docs
ykaiboussiSO 15a3a66
Add comments and update tests
ykaiboussiSO bc973d6
increase bdd test coverage
ykaiboussiSO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
| Feature: Match nodes | ||
|
|
||
| Scenario: Match non existed nodes | ||
| Given an empty graph | ||
| When executing query: | ||
| """ | ||
| MATCH (n) | ||
| RETURN n | ||
| """ | ||
| Then the result should be: | ||
| | n | | ||
|
|
||
| Scenario: Matching all nodes | ||
| Given an empty graph | ||
| And having executed: | ||
| """ | ||
| CREATE (:A), (:B {prefix: 'c', name: 'b'}), ({name: 'c'}) | ||
| """ | ||
| When executing query: | ||
| """ | ||
| MATCH (n) | ||
| RETURN n | ||
| """ | ||
| Then the result should be: | ||
| | n | | ||
| | (:A) | | ||
| | (:B{name: 'b', prefix: 'c'}) | | ||
| | ({name: 'c'}) | |
This file contains hidden or 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,84 @@ | ||
| // Copyright 2026 Specter Ops, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| //go:build bdd_integration | ||
|
|
||
| package bdd | ||
|
|
||
| import ( | ||
| "context" | ||
| "log" | ||
| "testing" | ||
|
|
||
| "github.com/cucumber/godog" | ||
| "github.com/specterops/dawgs/graph" | ||
| "github.com/specterops/dawgs/integration" | ||
| ) | ||
|
|
||
| func InitializeTestSuite(ctxtestsuite *godog.TestSuiteContext, ctx context.Context, c *dbContext) { | ||
| err := c.db.WriteTransaction(ctx, func(tx graph.Transaction) error { | ||
| if err := tx.Nodes().Delete(); err != nil { | ||
| return err | ||
| } | ||
| return nil | ||
| }) | ||
| if err != nil { | ||
| log.Fatalf("Failed to clear database %v", err) | ||
| } | ||
| } | ||
|
|
||
| func InitializeScenario(ctx *godog.ScenarioContext, dbCtx *dbContext) { | ||
| ctx.Step(`^an empty graph$`, dbCtx.anEmptyGraph) | ||
| ctx.Step(`^having executed:$`, dbCtx.havingExecuted) | ||
| ctx.Step(`^executing query:$`, dbCtx.executingQuery) | ||
| ctx.Step(`^the result should be:$`, dbCtx.theResultShouldBe) | ||
| } | ||
|
|
||
| func TestFeatures(t *testing.T) { | ||
| backgroundCtx := context.Background() | ||
| // establish database connection | ||
| session := integration.Open(t, integration.Options{ | ||
| Schema: &graph.Schema{ | ||
| DefaultGraph: graph.Graph{ | ||
| Name: "dawgs-bdd", | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| dbCtx := &dbContext{ | ||
| db: session.DB, | ||
| } | ||
| suite := godog.TestSuite{ | ||
| Name: "OpenCypher-TCK", | ||
| TestSuiteInitializer: func(ctx *godog.TestSuiteContext) { | ||
| InitializeTestSuite(ctx, backgroundCtx, dbCtx) | ||
| }, | ||
| ScenarioInitializer: func(ctx *godog.ScenarioContext) { | ||
| InitializeScenario(ctx, dbCtx) | ||
| }, | ||
| Options: &godog.Options{ | ||
| Format: "pretty", | ||
| // TODO create env variable pointing to the TCK features via CI | ||
| Paths: []string{"features"}, | ||
| TestingT: t, | ||
| }, | ||
| } | ||
|
|
||
| if num := suite.Run(); num != 0 { | ||
| t.Fatalf("TestSuite execution failed with status %d", num) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.