github.com/ethersphere/bee/v2@v2.2.0/pkg/file/pipeline/mock/writer.go (about) 1 // Copyright 2020 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package mock 6 7 import ( 8 "sync" 9 10 "github.com/ethersphere/bee/v2/pkg/file/pipeline" 11 ) 12 13 type MockChainWriter struct { 14 sync.Mutex 15 chainWriteCalls int 16 sumCalls int 17 } 18 19 func NewChainWriter() *MockChainWriter { 20 return &MockChainWriter{} 21 } 22 23 func (c *MockChainWriter) ChainWrite(_ *pipeline.PipeWriteArgs) error { 24 c.Lock() 25 defer c.Unlock() 26 c.chainWriteCalls++ 27 return nil 28 } 29 func (c *MockChainWriter) Sum() ([]byte, error) { 30 c.Lock() 31 defer c.Unlock() 32 c.sumCalls++ 33 return nil, nil 34 } 35 36 func (c *MockChainWriter) ChainWriteCalls() int { c.Lock(); defer c.Unlock(); return c.chainWriteCalls } 37 func (c *MockChainWriter) SumCalls() int { c.Lock(); defer c.Unlock(); return c.sumCalls }