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