Documentation
¶
Overview ¶
Package testutil provides shared test infrastructure for the knowing project.
Index ¶
- type MockGraphStore
- func (m *MockGraphStore) AddEdge(e types.Edge)
- func (m *MockGraphStore) AddNode(n types.Node)
- func (m *MockGraphStore) AddRepo(r types.Repo)
- func (m *MockGraphStore) AllRepos(_ context.Context) ([]types.Repo, error)
- func (m *MockGraphStore) BlastRadius(_ context.Context, _ types.Hash, _ types.Hash) (*types.BlastRadiusResult, error)
- func (m *MockGraphStore) Close() error
- func (m *MockGraphStore) CreateSnapshot(_ context.Context, s types.Snapshot) error
- func (m *MockGraphStore) DanglingEdges(_ context.Context) ([]types.Edge, error)
- func (m *MockGraphStore) DeleteEdge(_ context.Context, hash types.Hash) error
- func (m *MockGraphStore) DeleteEdgesBySourceFile(_ context.Context, fileHash types.Hash) ([]types.Edge, error)
- func (m *MockGraphStore) DeleteEdgesNotIn(_ context.Context, _ map[types.Hash]struct{}) (int64, error)
- func (m *MockGraphStore) DeleteNodesByFile(_ context.Context, fileHash types.Hash) (int, error)
- func (m *MockGraphStore) DeleteNodesNotIn(_ context.Context, _ map[types.Hash]struct{}) (int64, error)
- func (m *MockGraphStore) DeleteNote(_ context.Context, _ types.Hash, _ string) error
- func (m *MockGraphStore) DeleteNotesByObject(_ context.Context, _ types.Hash) error
- func (m *MockGraphStore) DeleteSnapshot(_ context.Context, hash types.Hash) error
- func (m *MockGraphStore) EdgesBySourceFile(_ context.Context, fileHash types.Hash) ([]types.Edge, error)
- func (m *MockGraphStore) EdgesFrom(_ context.Context, sourceHash types.Hash, _ string) ([]types.Edge, error)
- func (m *MockGraphStore) EdgesTo(_ context.Context, targetHash types.Hash, _ string) ([]types.Edge, error)
- func (m *MockGraphStore) FileByPath(_ context.Context, repoHash types.Hash, path string) (*types.File, error)
- func (m *MockGraphStore) FilesByRepo(_ context.Context, repoHash types.Hash) ([]types.File, error)
- func (m *MockGraphStore) GetEdge(_ context.Context, hash types.Hash) (*types.Edge, error)
- func (m *MockGraphStore) GetNode(_ context.Context, hash types.Hash) (*types.Node, error)
- func (m *MockGraphStore) GetNote(_ context.Context, _ types.Hash, _ string) (*types.Note, error)
- func (m *MockGraphStore) GetNotes(_ context.Context, _ types.Hash) ([]types.Note, error)
- func (m *MockGraphStore) GetNotesByKey(_ context.Context, _ string) ([]types.Note, error)
- func (m *MockGraphStore) GetRepo(_ context.Context, hash types.Hash) (*types.Repo, error)
- func (m *MockGraphStore) GetSnapshot(_ context.Context, hash types.Hash) (*types.Snapshot, error)
- func (m *MockGraphStore) LatestSnapshot(_ context.Context, _ types.Hash) (*types.Snapshot, error)
- func (m *MockGraphStore) NodesByFilePath(_ context.Context, repoHash types.Hash, path string) ([]types.Node, error)
- func (m *MockGraphStore) NodesByName(_ context.Context, prefix string) ([]types.Node, error)
- func (m *MockGraphStore) NodesByQualifiedName(_ context.Context, qualifiedName string) ([]types.Node, error)
- func (m *MockGraphStore) PutEdge(_ context.Context, e types.Edge) error
- func (m *MockGraphStore) PutFile(_ context.Context, f types.File) error
- func (m *MockGraphStore) PutNode(_ context.Context, n types.Node) error
- func (m *MockGraphStore) PutNote(_ context.Context, _ types.Note) error
- func (m *MockGraphStore) PutRepo(_ context.Context, r types.Repo) error
- func (m *MockGraphStore) RecordEdgeEvent(_ context.Context, ev types.EdgeEvent) error
- func (m *MockGraphStore) SnapshotDiff(_ context.Context, _, _ types.Hash) (*types.DiffResult, error)
- func (m *MockGraphStore) StaleEdges(_ context.Context, _ types.Hash) ([]types.Edge, error)
- func (m *MockGraphStore) StaleNodesByFiles(_ context.Context, _ types.Hash, _ []string) ([]types.Node, error)
- func (m *MockGraphStore) String() string
- func (m *MockGraphStore) TransitiveCallees(_ context.Context, _ types.Hash, _ int, _ types.Hash) ([]types.CalleeResult, error)
- func (m *MockGraphStore) TransitiveCallers(_ context.Context, _ types.Hash, _ int, _ types.Hash) ([]types.CallerResult, error)
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) BlastRadius ¶
func (m *MockGraphStore) BlastRadius(_ context.Context, _ types.Hash, _ types.Hash) (*types.BlastRadiusResult, error)
func (*MockGraphStore) Close ¶
func (m *MockGraphStore) Close() error
func (*MockGraphStore) CreateSnapshot ¶
func (*MockGraphStore) DanglingEdges ¶
func (*MockGraphStore) DeleteEdge ¶
func (*MockGraphStore) DeleteEdgesBySourceFile ¶
func (*MockGraphStore) DeleteEdgesNotIn ¶
func (*MockGraphStore) DeleteNodesByFile ¶
func (*MockGraphStore) DeleteNodesNotIn ¶
func (*MockGraphStore) DeleteNote ¶
func (*MockGraphStore) DeleteNotesByObject ¶
func (*MockGraphStore) DeleteSnapshot ¶
func (*MockGraphStore) EdgesBySourceFile ¶
func (*MockGraphStore) FileByPath ¶
func (*MockGraphStore) FilesByRepo ¶
func (*MockGraphStore) GetNotesByKey ¶
func (*MockGraphStore) GetSnapshot ¶
func (*MockGraphStore) LatestSnapshot ¶
func (*MockGraphStore) NodesByFilePath ¶
func (*MockGraphStore) NodesByName ¶
func (*MockGraphStore) NodesByQualifiedName ¶
func (*MockGraphStore) RecordEdgeEvent ¶
func (*MockGraphStore) SnapshotDiff ¶
func (m *MockGraphStore) SnapshotDiff(_ context.Context, _, _ types.Hash) (*types.DiffResult, error)
func (*MockGraphStore) StaleEdges ¶
func (*MockGraphStore) StaleNodesByFiles ¶
func (*MockGraphStore) String ¶
func (m *MockGraphStore) String() string
String implements fmt.Stringer for debugging.