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

     1  package settings
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/cozy/cozy-stack/model/instance"
     7  	"github.com/cozy/cozy-stack/pkg/couchdb"
     8  	"github.com/cozy/cozy-stack/pkg/prefixer"
     9  	"github.com/stretchr/testify/mock"
    10  )
    11  
    12  // Mock implementation of [Service].
    13  type Mock struct {
    14  	mock.Mock
    15  }
    16  
    17  // NewServiceMock instantiates a new [Mock].
    18  func NewServiceMock(t *testing.T) *Mock {
    19  	m := new(Mock)
    20  	m.Test(t)
    21  	t.Cleanup(func() { m.AssertExpectations(t) })
    22  
    23  	return m
    24  }
    25  
    26  // PublicName mock method.
    27  func (m *Mock) PublicName(db prefixer.Prefixer) (string, error) {
    28  	args := m.Called(db)
    29  
    30  	return args.String(0), args.Error(1)
    31  }
    32  
    33  // GetInstanceSettings mock method.
    34  func (m *Mock) GetInstanceSettings(db prefixer.Prefixer) (*couchdb.JSONDoc, error) {
    35  	args := m.Called(db)
    36  
    37  	if args.Get(0) == nil {
    38  		return nil, args.Error(1)
    39  	}
    40  
    41  	return args.Get(0).(*couchdb.JSONDoc), args.Error(1)
    42  }
    43  
    44  // SetInstanceSettings mock method.
    45  func (m *Mock) SetInstanceSettings(db prefixer.Prefixer, doc *couchdb.JSONDoc) error {
    46  	return m.Called(db, doc).Error(0)
    47  }
    48  
    49  // StartEmailUpdate mock method.
    50  func (m *Mock) StartEmailUpdate(inst *instance.Instance, cmd *UpdateEmailCmd) error {
    51  	return m.Called(inst, cmd).Error(0)
    52  }
    53  
    54  // ResendEmailUpdate mock method.
    55  func (m *Mock) ResendEmailUpdate(inst *instance.Instance) error {
    56  	return m.Called(inst).Error(0)
    57  }
    58  
    59  // ConfirmEmailUpdate mock method.
    60  func (m *Mock) ConfirmEmailUpdate(inst *instance.Instance, tok string) error {
    61  	return m.Called(inst, tok).Error(0)
    62  }
    63  
    64  // CancelEmailUpdate mock method.
    65  func (m *Mock) CancelEmailUpdate(inst *instance.Instance) error {
    66  	return m.Called(inst).Error(0)
    67  }
    68  
    69  func (m *Mock) GetExternalTies(inst *instance.Instance) (*ExternalTies, error) {
    70  	args := m.Called(inst)
    71  
    72  	if args.Get(0) == nil {
    73  		return nil, args.Error(1)
    74  	}
    75  
    76  	return args.Get(0).(*ExternalTies), args.Error(1)
    77  }