Skip to content

Commit 7dfdd91

Browse files
committed
remove module refrences from mock core repo test file
1 parent 963d434 commit 7dfdd91

File tree

1 file changed

+4
-72
lines changed

1 file changed

+4
-72
lines changed

test/mock_core_repository.go

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// - AddNode to return (string, error)
44
// - AddNodeWithID to return error
55
// - GetLinks to return []*core.Link
6-
// - GetModule to return (core.Module, bool)
76
// - ListNodes to return ([]string, error)
87

98
package test
@@ -16,19 +15,15 @@ import (
1615

1716
// MockCoreRepository is a test double implementing core.Repository for migration tests.
1817
type MockCoreRepository struct {
19-
nodes map[string]*core.Node
20-
links map[string][]*core.Link
21-
modules map[string]core.Module
22-
enabledModules map[string]bool
18+
nodes map[string]*core.Node
19+
links map[string][]*core.Link
2320
}
2421

2522
// NewMockCoreRepository builds a fresh in-memory repository that satisfies core.Repository.
2623
func NewMockCoreRepository() *MockCoreRepository {
2724
return &MockCoreRepository{
28-
nodes: make(map[string]*core.Node),
29-
links: make(map[string][]*core.Link),
30-
modules: make(map[string]core.Module),
31-
enabledModules: make(map[string]bool),
25+
nodes: make(map[string]*core.Node),
26+
links: make(map[string][]*core.Link),
3227
}
3328
}
3429

@@ -129,69 +124,6 @@ func (r *MockCoreRepository) QueryLinks(nodeID string) ([]*core.Link, error) {
129124
return r.links[nodeID], nil
130125
}
131126

132-
// GetModule returns a module by ID.
133-
func (r *MockCoreRepository) GetModule(id string) (core.Module, bool) {
134-
m, ok := r.modules[id]
135-
return m, ok
136-
}
137-
138-
// RegisterModule registers a new module.
139-
func (r *MockCoreRepository) RegisterModule(mod core.Module) error {
140-
if _, exists := r.modules[mod.ID()]; exists {
141-
return fmt.Errorf("module already registered: %s", mod.ID())
142-
}
143-
r.modules[mod.ID()] = mod
144-
r.enabledModules[mod.ID()] = true
145-
return nil
146-
}
147-
148-
// UnregisterModule removes a module.
149-
func (r *MockCoreRepository) UnregisterModule(moduleID string) error {
150-
if _, exists := r.modules[moduleID]; !exists {
151-
return fmt.Errorf("module not found: %s", moduleID)
152-
}
153-
delete(r.modules, moduleID)
154-
delete(r.enabledModules, moduleID)
155-
return nil
156-
}
157-
158-
// ListModules returns all registered modules.
159-
func (r *MockCoreRepository) ListModules() []core.Module {
160-
var out []core.Module
161-
for _, mod := range r.modules {
162-
out = append(out, mod)
163-
}
164-
return out
165-
}
166-
167-
// QueryNodesByModule filters nodes by "module" field in metadata.
168-
func (r *MockCoreRepository) QueryNodesByModule(moduleID string) ([]*core.Node, error) {
169-
var results []*core.Node
170-
for _, nd := range r.nodes {
171-
if nd.Meta != nil {
172-
if modID, ok := nd.Meta["module"].(string); ok && modID == moduleID {
173-
results = append(results, nd)
174-
}
175-
}
176-
}
177-
return results, nil
178-
}
179-
180-
// QueryLinksByModule filters links by "module" field in metadata.
181-
func (r *MockCoreRepository) QueryLinksByModule(moduleID string) ([]*core.Link, error) {
182-
var results []*core.Link
183-
for _, bucket := range r.links {
184-
for _, l := range bucket {
185-
if l.Meta != nil {
186-
if modID, ok := l.Meta["module"].(string); ok && modID == moduleID {
187-
results = append(results, l)
188-
}
189-
}
190-
}
191-
}
192-
return results, nil
193-
}
194-
195127
// GetContent fetches the node's content by ID.
196128
func (r *MockCoreRepository) GetContent(id string) ([]byte, error) {
197129
n, ok := r.nodes[id]

0 commit comments

Comments
 (0)