integration

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ConnectionStringEnv = "CONNECTION_STRING"

Variables

This section is empty.

Functions

func AssertIDSet

func AssertIDSet(t *testing.T, got, expected []string)

AssertIDSet checks that two sets of fixture node IDs match (order-independent).

func AssertPaths

func AssertPaths(t *testing.T, paths []graph.Path, idMap opengraph.IDMap, expected [][]string)

AssertPaths checks that the returned paths match the expected set of fixture node ID sequences. Each expected path is a slice of fixture node IDs, e.g. []string{"a", "b", "d"}. Pass nil for expected when no paths should be returned.

func ClearGraph

func ClearGraph(t *testing.T, db graph.Database, ctx context.Context)

ClearGraph deletes all nodes (and cascading edges) from the database.

func DriverFromConnectionString added in v0.6.0

func DriverFromConnectionString(connStr string) (string, error)

DriverFromConnStr returns the dawgs driver name based on the connection string scheme.

func LoadDataset

func LoadDataset(t *testing.T, db graph.Database, ctx context.Context, name string) opengraph.IDMap

LoadDataset loads a named JSON dataset from testdata/ and returns the ID mapping.

func QueryNodeIDs

func QueryNodeIDs(t *testing.T, ctx context.Context, db graph.Database, cypher string, idMap opengraph.IDMap) []string

QueryNodeIDs runs a Cypher query that returns nodes and collects their fixture IDs. Duplicate nodes are deduplicated.

func QueryPaths

func QueryPaths(t *testing.T, ctx context.Context, db graph.Database, cypher string) []graph.Path

QueryPaths runs a Cypher query and collects all returned paths.

func SetupDB

func SetupDB(t *testing.T, cleanupMode CleanupMode, datasets ...string) (graph.Database, context.Context)

SetupDB opens a database connection for the selected driver, asserts a schema derived from the given datasets, and registers cleanup. Returns the database and a background context.

func SetupDBWithKinds added in v0.5.0

func SetupDBWithKinds(t *testing.T, cleanupMode CleanupMode, extraNodeKinds, extraEdgeKinds graph.Kinds, datasets ...string) (graph.Database, context.Context)

SetupDBWithKinds opens a database connection like SetupDB, then extends the asserted schema with additional node and edge kinds.

func SetupDBWithKindsNoGraphCleanup added in v0.5.0

func SetupDBWithKindsNoGraphCleanup(t *testing.T, extraNodeKinds, extraEdgeKinds graph.Kinds, datasets ...string) (graph.Database, context.Context)

SetupDBWithKindsNoGraphCleanup opens a database connection like SetupDBWithKinds but only closes the connection during cleanup. Use this for rollback-only tests that must not clear a shared database.

Types

type CleanupMode added in v0.6.0

type CleanupMode int
const (
	CleanupGraph CleanupMode = iota
	CloseOnly
)

type Options added in v0.6.0

type Options struct {
	RequireDriver          string
	SkipIfNoConnection     bool
	SkipIfDriverMismatch   bool
	ConnectionStringEnvVar string
	GraphName              string
	GraphQueryMemoryLimit  size.Size
	Schema                 *graph.Schema
	ExtraNodeKinds         graph.Kinds
	ExtraEdgeKinds         graph.Kinds
	Datasets               []string
	DatasetPath            func(name string) string
	CleanupMode            CleanupMode
}

type Session added in v0.6.0

type Session struct {
	ConnectionString string
	Driver           string
	DB               graph.Database
	PGPool           *pgxpool.Pool
	Ctx              context.Context
}

func Open added in v0.6.0

func Open(t *testing.T, opts Options) *Session

func (*Session) ClearGraph added in v0.6.0

func (s *Session) ClearGraph(t *testing.T)

func (*Session) LoadDataset added in v0.6.0

func (s *Session) LoadDataset(t *testing.T, path string) opengraph.IDMap

func (*Session) WithRollback added in v0.6.0

func (s *Session) WithRollback(t *testing.T, delegate func(tx graph.Transaction) error) error

func (*Session) WithRollbackFixture added in v0.6.0

func (s *Session) WithRollbackFixture(t *testing.T, fixture *opengraph.Graph, clearGraph bool, delegate func(tx graph.Transaction, idMap opengraph.IDMap) error) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL