github.com/cozy/cozy-stack@v0.0.0-20240327093429-939e4a21320e/model/instance/service_mock.go (about) 1 package instance 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/mock" 7 ) 8 9 // Mock implementation of 10 type Mock struct { 11 mock.Mock 12 } 13 14 // NewMock instantiates a new [Mock]. 15 func NewMock(t *testing.T) *Mock { 16 m := new(Mock) 17 m.Test(t) 18 19 t.Cleanup(func() { m.AssertExpectations(t) }) 20 21 return m 22 } 23 24 // Get mock method. 25 func (m *Mock) Get(domain string) (*Instance, error) { 26 args := m.Called(domain) 27 28 if args.Get(0) == nil { 29 return nil, args.Error(1) 30 } 31 32 return args.Get(0).(*Instance), args.Error(1) 33 } 34 35 // GetWithoutCache mock method. 36 func (m *Mock) GetWithoutCache(domain string) (*Instance, error) { 37 args := m.Called(domain) 38 39 if args.Get(0) == nil { 40 return nil, args.Error(1) 41 } 42 43 return args.Get(0).(*Instance), args.Error(1) 44 } 45 46 // Update mock method. 47 func (m *Mock) Update(inst *Instance) error { 48 return m.Called(inst).Error(1) 49 } 50 51 // Delete mock method. 52 func (m *Mock) Delete(inst *Instance) error { 53 return m.Called(inst).Error(1) 54 } 55 56 // CheckPassphrase mock method. 57 func (m *Mock) CheckPassphrase(inst *Instance, pass []byte) error { 58 return m.Called(inst, pass).Error(0) 59 }