github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/token/service_mock.go (about) 1 package token 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/cozy/cozy-stack/pkg/prefixer" 8 "github.com/stretchr/testify/mock" 9 ) 10 11 // Mock implementation of [Service]. 12 type Mock struct { 13 mock.Mock 14 } 15 16 // NewMock instantiates a new Mock. 17 func NewMock(t *testing.T) *Mock { 18 m := new(Mock) 19 m.Test(t) 20 21 t.Cleanup(func() { m.AssertExpectations(t) }) 22 23 return m 24 } 25 26 // GenerateAndSave mock method. 27 func (m *Mock) GenerateAndSave(db prefixer.Prefixer, op Operation, resource string, lifetime time.Duration) (string, error) { 28 args := m.Called(db, op, resource, lifetime) 29 30 return args.String(0), args.Error(1) 31 } 32 33 // Validate mock method. 34 func (m *Mock) Validate(db prefixer.Prefixer, op Operation, resource, token string) error { 35 return m.Called(db, op, resource, token).Error(0) 36 }