github.com/ethersphere/bee/v2@v2.2.0/pkg/pushsync/mock/mock.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  	"context"
     9  
    10  	"github.com/ethersphere/bee/v2/pkg/pushsync"
    11  	"github.com/ethersphere/bee/v2/pkg/swarm"
    12  )
    13  
    14  type mock struct {
    15  	sendChunk func(ctx context.Context, chunk swarm.Chunk) (*pushsync.Receipt, error)
    16  }
    17  
    18  func New(sendChunk func(ctx context.Context, chunk swarm.Chunk) (*pushsync.Receipt, error)) pushsync.PushSyncer {
    19  	return &mock{sendChunk: sendChunk}
    20  }
    21  
    22  func (s *mock) PushChunkToClosest(ctx context.Context, chunk swarm.Chunk) (*pushsync.Receipt, error) {
    23  	return s.sendChunk(ctx, chunk)
    24  }
    25  
    26  func (s *mock) Close() error {
    27  	return nil
    28  }