-
Notifications
You must be signed in to change notification settings - Fork 177
/
collection_store.go
52 lines (41 loc) · 1.29 KB
/
collection_store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mocks
import (
"fmt"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/storage"
)
type MockCollectionStore struct {
byID map[flow.Identifier]*flow.Collection
}
func NewMockCollectionStore() *MockCollectionStore {
return &MockCollectionStore{
byID: make(map[flow.Identifier]*flow.Collection),
}
}
func (m *MockCollectionStore) ByID(id flow.Identifier) (*flow.Collection, error) {
c, ok := m.byID[id]
if !ok {
return nil, fmt.Errorf("collection %s not found: %w", id, storage.ErrNotFound)
}
return c, nil
}
func (m *MockCollectionStore) Store(c *flow.Collection) error {
m.byID[c.ID()] = c
return nil
}
func (m *MockCollectionStore) StoreLightAndIndexByTransaction(collection *flow.LightCollection) error {
panic("StoreLightIndexByTransaction not implemented")
}
func (m *MockCollectionStore) StoreLight(collection *flow.LightCollection) error {
panic("StoreLight not implemented")
}
func (m *MockCollectionStore) Remove(id flow.Identifier) error {
delete(m.byID, id)
return nil
}
func (m *MockCollectionStore) LightByID(id flow.Identifier) (*flow.LightCollection, error) {
panic("LightByID not implemented")
}
func (m *MockCollectionStore) LightByTransactionID(id flow.Identifier) (*flow.LightCollection, error) {
panic("LightByTransactionID not implemented")
}