Documentation
¶
Index ¶
- Constants
- func AssertIDSet(t *testing.T, got, expected []string)
- func AssertPaths(t *testing.T, paths []graph.Path, idMap opengraph.IDMap, expected [][]string)
- func ClearGraph(t *testing.T, db graph.Database, ctx context.Context)
- func DriverFromConnectionString(connStr string) (string, error)
- func FixtureKinds(count int) []string
- func FixtureNames(prefix string, count int) []string
- func LoadDataset(t *testing.T, db graph.Database, ctx context.Context, name string) opengraph.IDMap
- func NewReconciliationFixture(fanout int) *opengraph.Graph
- func QueryNodeIDs(t *testing.T, ctx context.Context, db graph.Database, cypher string, ...) []string
- func QueryPaths(t *testing.T, ctx context.Context, db graph.Database, cypher string) []graph.Path
- func SetupDB(t *testing.T, cleanupMode CleanupMode, datasets ...string) (graph.Database, context.Context)
- func SetupDBWithKinds(t *testing.T, cleanupMode CleanupMode, ...) (graph.Database, context.Context)
- func SetupDBWithKindsNoGraphCleanup(t *testing.T, extraNodeKinds, extraEdgeKinds graph.Kinds, datasets ...string) (graph.Database, context.Context)
- type CleanupMode
- type Options
- type Session
- func (s *Session) ClearGraph(t *testing.T)
- func (s *Session) Close() error
- func (s *Session) LoadDataset(t *testing.T, path string) opengraph.IDMap
- func (s *Session) RegisterGraphCleanup(t testing.TB)
- func (s *Session) ResetGraph() error
- func (s *Session) WithRollback(t *testing.T, delegate func(tx graph.Transaction) error) error
- func (s *Session) WithRollbackFixture(t *testing.T, fixture *opengraph.Graph, clearGraph bool, ...) error
Constants ¶
const ConnectionStringEnv = "CONNECTION_STRING"
ConnectionStringEnv names the default environment variable read by integration sessions.
Variables ¶
This section is empty.
Functions ¶
func AssertIDSet ¶
AssertIDSet checks that two sets of fixture node IDs match (order-independent).
func AssertPaths ¶
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 ¶
ClearGraph deletes all nodes (and cascading edges) from the database.
func DriverFromConnectionString ¶ added in v0.6.0
DriverFromConnectionString maps postgres/postgresql and neo4j/neo4j+s/neo4j+ssc URI schemes to their registered driver names.
func FixtureKinds ¶ added in v1.0.0
FixtureKinds returns deterministic synthetic kind names for list-cardinality tests.
func FixtureNames ¶ added in v1.0.0
FixtureNames returns deterministic fixture identifiers without committing large handwritten lists to the corpus.
func LoadDataset ¶
LoadDataset loads a named JSON dataset from testdata/ and returns the ID mapping.
func NewReconciliationFixture ¶ added in v1.0.0
NewReconciliationFixture builds the reusable reconciliation fixture. It includes typed and multi-kind endpoints, duplicate relationship kinds, missing and explicit-null properties, timestamps, both directions, and a deterministic high-degree anchor. A non-positive fanout selects a small production-like default.
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 ¶
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 removes graph data when an integration session closes. CleanupGraph CleanupMode = iota // CloseOnly closes an integration session without deleting graph data. 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 identifies the configured backend connection used by this session.
ConnectionString string
// Driver names the registered graph driver selected by the connection scheme.
Driver string
// DB owns the opened graph database and its default graph selection.
DB graph.Database
// PGPool provides PostgreSQL-specific inspection when the selected driver supports it.
PGPool *pgxpool.Pool
// Ctx supplies the context shared by session operations and cleanup.
Ctx context.Context
// contains filtered or unexported fields
}
Session owns a backend connection, default graph and cleanup policy for integration work.
func OpenSession ¶ added in v1.0.0
OpenSession opens the configured database, initializes its schema, and returns an integration session.
func (*Session) ClearGraph ¶ added in v0.6.0
ClearGraph removes the session graph's data and fails the caller's test on cleanup errors.
func (*Session) Close ¶ added in v1.0.0
Close applies the configured cleanup mode and closes the database connection.
func (*Session) LoadDataset ¶ added in v0.6.0
func (*Session) RegisterGraphCleanup ¶ added in v1.0.0
RegisterGraphCleanup resets the graph at the end of the supplied test scope. It is intended for subtests sharing a session opened by their parent test.
func (*Session) ResetGraph ¶ added in v1.0.0
ResetGraph removes all nodes and cascading edges from the session database.