github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/cloudery/service_mock.go (about)

     1  package cloudery
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/cozy/cozy-stack/model/instance"
     7  	"github.com/stretchr/testify/mock"
     8  )
     9  
    10  // Mock impelementation of [Service].
    11  type Mock struct {
    12  	mock.Mock
    13  }
    14  
    15  // NewMock instantiates a new [Mock].
    16  func NewMock(t *testing.T) *Mock {
    17  	m := new(Mock)
    18  	m.Test(t)
    19  	t.Cleanup(func() { m.AssertExpectations(t) })
    20  
    21  	return m
    22  }
    23  
    24  // SaveInstance mock method.
    25  func (m *Mock) SaveInstance(inst *instance.Instance, cmd *SaveCmd) error {
    26  	return m.Called(inst, cmd).Error(0)
    27  }
    28  
    29  func (m *Mock) BlockingSubscription(inst *instance.Instance) (*BlockingSubscription, error) {
    30  	args := m.Called(inst)
    31  
    32  	if args.Get(0) == nil {
    33  		return nil, args.Error(1)
    34  	}
    35  
    36  	return args.Get(0).(*BlockingSubscription), args.Error(1)
    37  }