testutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package testutil provides shared test infrastructure for the knowing project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockGraphStore

type MockGraphStore struct {
	// Data maps for point lookups.
	Nodes     map[types.Hash]*types.Node
	Edges     map[types.Hash]*types.Edge
	Snapshots map[types.Hash]*types.Snapshot
	Repos     map[types.Hash]*types.Repo
	Files     map[types.Hash]*types.File

	// Indexed data for query methods.
	NodesByNameResult map[string][]types.Node
	EdgesFromResult   map[types.Hash][]types.Edge
	EdgesToResult     map[types.Hash][]types.Edge
	FilesByRepoResult map[types.Hash][]types.File

	// Results for traversal methods.
	TransitiveCallersResult []types.CallerResult
	TransitiveCalleesResult []types.CalleeResult
	BlastRadiusResult       *types.BlastRadiusResult
	SnapshotDiffResult      *types.DiffResult
	StaleEdgesResult        []types.Edge
	LatestSnapshotResult    *types.Snapshot

	// Mutation tracking.
	PutEdges         []types.Edge
	PutNodes         []types.Node
	DeletedEdges     []types.Hash
	CreatedSnapshots []types.Snapshot
	EdgeEvents       []types.EdgeEvent
}

MockGraphStore is a shared test double for types.GraphStore. All methods are no-ops returning nil/zero values by default. Embed this in test-specific mocks and override only needed methods.

Exported map fields allow tests to pre-populate data for point lookups. Override result fields (e.g., NodesByNameResult) control what query methods return. Mutation tracking fields (e.g., PutEdges, DeletedEdges) capture write operations.

func NewMockGraphStore

func NewMockGraphStore() *MockGraphStore

NewMockGraphStore creates a MockGraphStore with initialized maps.

func (*MockGraphStore) AddEdge

func (m *MockGraphStore) AddEdge(e types.Edge)

AddEdge adds an edge to the store for testing.

func (*MockGraphStore) AddNode

func (m *MockGraphStore) AddNode(n types.Node)

AddNode adds a node to the store for testing.

func (*MockGraphStore) AddRepo

func (m *MockGraphStore) AddRepo(r types.Repo)

AddRepo adds a repo to the store for testing.

func (*MockGraphStore) AllRepos

func (m *MockGraphStore) AllRepos(_ context.Context) ([]types.Repo, error)

func (*MockGraphStore) BlastRadius

func (*MockGraphStore) Close

func (m *MockGraphStore) Close() error

func (*MockGraphStore) CreateSnapshot

func (m *MockGraphStore) CreateSnapshot(_ context.Context, s types.Snapshot) error

func (*MockGraphStore) DanglingEdges

func (m *MockGraphStore) DanglingEdges(_ context.Context) ([]types.Edge, error)

func (*MockGraphStore) DeleteEdge

func (m *MockGraphStore) DeleteEdge(_ context.Context, hash types.Hash) error

func (*MockGraphStore) DeleteEdgesBySourceFile

func (m *MockGraphStore) DeleteEdgesBySourceFile(_ context.Context, fileHash types.Hash) ([]types.Edge, error)

func (*MockGraphStore) DeleteEdgesNotIn

func (m *MockGraphStore) DeleteEdgesNotIn(_ context.Context, _ map[types.Hash]struct{}) (int64, error)

func (*MockGraphStore) DeleteNodesByFile

func (m *MockGraphStore) DeleteNodesByFile(_ context.Context, fileHash types.Hash) (int, error)

func (*MockGraphStore) DeleteNodesNotIn

func (m *MockGraphStore) DeleteNodesNotIn(_ context.Context, _ map[types.Hash]struct{}) (int64, error)

func (*MockGraphStore) DeleteNote

func (m *MockGraphStore) DeleteNote(_ context.Context, _ types.Hash, _ string) error

func (*MockGraphStore) DeleteNotesByObject

func (m *MockGraphStore) DeleteNotesByObject(_ context.Context, _ types.Hash) error

func (*MockGraphStore) DeleteSnapshot

func (m *MockGraphStore) DeleteSnapshot(_ context.Context, hash types.Hash) error

func (*MockGraphStore) EdgesBySourceFile

func (m *MockGraphStore) EdgesBySourceFile(_ context.Context, fileHash types.Hash) ([]types.Edge, error)

func (*MockGraphStore) EdgesFrom

func (m *MockGraphStore) EdgesFrom(_ context.Context, sourceHash types.Hash, _ string) ([]types.Edge, error)

func (*MockGraphStore) EdgesTo

func (m *MockGraphStore) EdgesTo(_ context.Context, targetHash types.Hash, _ string) ([]types.Edge, error)

func (*MockGraphStore) FileByPath

func (m *MockGraphStore) FileByPath(_ context.Context, repoHash types.Hash, path string) (*types.File, error)

func (*MockGraphStore) FilesByRepo

func (m *MockGraphStore) FilesByRepo(_ context.Context, repoHash types.Hash) ([]types.File, error)

func (*MockGraphStore) GetEdge

func (m *MockGraphStore) GetEdge(_ context.Context, hash types.Hash) (*types.Edge, error)

func (*MockGraphStore) GetNode

func (m *MockGraphStore) GetNode(_ context.Context, hash types.Hash) (*types.Node, error)

func (*MockGraphStore) GetNote

func (m *MockGraphStore) GetNote(_ context.Context, _ types.Hash, _ string) (*types.Note, error)

func (*MockGraphStore) GetNotes

func (m *MockGraphStore) GetNotes(_ context.Context, _ types.Hash) ([]types.Note, error)

func (*MockGraphStore) GetNotesByKey

func (m *MockGraphStore) GetNotesByKey(_ context.Context, _ string) ([]types.Note, error)

func (*MockGraphStore) GetRepo

func (m *MockGraphStore) GetRepo(_ context.Context, hash types.Hash) (*types.Repo, error)

func (*MockGraphStore) GetSnapshot

func (m *MockGraphStore) GetSnapshot(_ context.Context, hash types.Hash) (*types.Snapshot, error)

func (*MockGraphStore) LatestSnapshot

func (m *MockGraphStore) LatestSnapshot(_ context.Context, _ types.Hash) (*types.Snapshot, error)

func (*MockGraphStore) NodesByFileHash added in v0.9.0

func (m *MockGraphStore) NodesByFileHash(_ context.Context, fileHash types.Hash) ([]types.Node, error)

func (*MockGraphStore) NodesByFilePath

func (m *MockGraphStore) NodesByFilePath(_ context.Context, repoHash types.Hash, path string) ([]types.Node, error)

func (*MockGraphStore) NodesByName

func (m *MockGraphStore) NodesByName(_ context.Context, prefix string) ([]types.Node, error)

func (*MockGraphStore) NodesByQualifiedName

func (m *MockGraphStore) NodesByQualifiedName(_ context.Context, qualifiedName string) ([]types.Node, error)

func (*MockGraphStore) PutEdge

func (m *MockGraphStore) PutEdge(_ context.Context, e types.Edge) error

func (*MockGraphStore) PutFile

func (m *MockGraphStore) PutFile(_ context.Context, f types.File) error

func (*MockGraphStore) PutNode

func (m *MockGraphStore) PutNode(_ context.Context, n types.Node) error

func (*MockGraphStore) PutNote

func (m *MockGraphStore) PutNote(_ context.Context, _ types.Note) error

func (*MockGraphStore) PutRepo

func (m *MockGraphStore) PutRepo(_ context.Context, r types.Repo) error

func (*MockGraphStore) RecordEdgeEvent

func (m *MockGraphStore) RecordEdgeEvent(_ context.Context, ev types.EdgeEvent) error

func (*MockGraphStore) SnapshotDiff

func (m *MockGraphStore) SnapshotDiff(_ context.Context, _, _ types.Hash) (*types.DiffResult, error)

func (*MockGraphStore) StaleEdges

func (m *MockGraphStore) StaleEdges(_ context.Context, _ types.Hash) ([]types.Edge, error)

func (*MockGraphStore) StaleNodesByFiles

func (m *MockGraphStore) StaleNodesByFiles(_ context.Context, _ types.Hash, _ []string) ([]types.Node, error)

func (*MockGraphStore) String

func (m *MockGraphStore) String() string

String implements fmt.Stringer for debugging.

func (*MockGraphStore) TransitiveCallees

func (m *MockGraphStore) TransitiveCallees(_ context.Context, _ types.Hash, _ int, _ types.Hash) ([]types.CalleeResult, error)

func (*MockGraphStore) TransitiveCallers

func (m *MockGraphStore) TransitiveCallers(_ context.Context, _ types.Hash, _ int, _ types.Hash) ([]types.CallerResult, error)

Jump to

Keyboard shortcuts

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