2021-03-15 12:51:15 +01:00
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-11-22 12:56:43 +02:00
|
|
|
"go.uber.org/mock/gomock"
|
2021-03-15 12:51:15 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewIDGenerator(t *testing.T) *MockGenerator {
|
|
|
|
m := NewMockGenerator(gomock.NewController(t))
|
|
|
|
m.EXPECT().Next().Return("1", nil)
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewIDGeneratorExpectIDs(t *testing.T, ids ...string) *MockGenerator {
|
|
|
|
m := NewMockGenerator(gomock.NewController(t))
|
|
|
|
for _, id := range ids {
|
|
|
|
m.EXPECT().Next().Return(id, nil)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExpectID(t *testing.T, id string) *MockGenerator {
|
|
|
|
m := NewMockGenerator(gomock.NewController(t))
|
|
|
|
m.EXPECT().Next().Return(id, nil)
|
|
|
|
return m
|
|
|
|
}
|
2023-05-05 17:34:53 +02:00
|
|
|
|
|
|
|
func NewIDGeneratorExpectError(t *testing.T, err error) *MockGenerator {
|
|
|
|
m := NewMockGenerator(gomock.NewController(t))
|
|
|
|
m.EXPECT().Next().Return("", err)
|
|
|
|
return m
|
|
|
|
}
|