@@ -10,7 +10,11 @@ type OutboxMock struct {
1010 updateMethodError error
1111 updateMethodCall int
1212 updateMethodFailsCall int
13+ requeueMethodError error
14+ requeueMethodCall int
15+ requeueMethodFailsCall int
1316 email outbox.Email
17+ lastMethod string
1418}
1519
1620type OutboxMockOptions func (* OutboxMock )
@@ -33,6 +37,18 @@ func UpdateMethodFailsCall(updateMethodFailsCall int) OutboxMockOptions {
3337 }
3438}
3539
40+ func RequeueMethodError (requeueMethodError error ) OutboxMockOptions {
41+ return func (o * OutboxMock ) {
42+ o .requeueMethodError = requeueMethodError
43+ }
44+ }
45+
46+ func RequeueMethodFailsCall (requeueMethodFailsCall int ) OutboxMockOptions {
47+ return func (o * OutboxMock ) {
48+ o .requeueMethodFailsCall = requeueMethodFailsCall
49+ }
50+ }
51+
3652func Email (email outbox.Email ) OutboxMockOptions {
3753 return func (o * OutboxMock ) {
3854 o .email = email
@@ -45,7 +61,11 @@ func NewOutboxMock(opts ...OutboxMockOptions) *OutboxMock {
4561 updateMethodError : nil ,
4662 updateMethodCall : 0 ,
4763 updateMethodFailsCall : 1 ,
64+ requeueMethodError : nil ,
65+ requeueMethodCall : 0 ,
66+ requeueMethodFailsCall : 1 ,
4867 email : outbox.Email {},
68+ lastMethod : "" ,
4969 }
5070 for _ , opt := range opts {
5171 opt (o )
@@ -54,10 +74,12 @@ func NewOutboxMock(opts ...OutboxMockOptions) *OutboxMock {
5474}
5575
5676func (m * OutboxMock ) Query (ctx context.Context , status string , limit int ) ([]outbox.Email , error ) {
77+ m .lastMethod = "query"
5778 return []outbox.Email {m .email }, m .queryMethodError
5879}
5980
6081func (m * OutboxMock ) Update (ctx context.Context , id string , status string , errorReason string , ttl * int64 ) error {
82+ m .lastMethod = "update"
6183 m .updateMethodCall ++
6284 if m .updateMethodCall == m .updateMethodFailsCall {
6385 return m .updateMethodError
@@ -66,9 +88,23 @@ func (m *OutboxMock) Update(ctx context.Context, id string, status string, error
6688}
6789
6890func (m * OutboxMock ) Ready (ctx context.Context , id string , emlFilePath string , ttl * int64 ) error {
91+ m .lastMethod = "ready"
6992 m .updateMethodCall ++
7093 if m .updateMethodCall == m .updateMethodFailsCall {
7194 return m .updateMethodError
7295 }
7396 return nil
7497}
98+
99+ func (m * OutboxMock ) Requeue (ctx context.Context , id string , ttl * int64 ) error {
100+ m .lastMethod = "requeue"
101+ m .requeueMethodCall ++
102+ if m .requeueMethodCall == m .requeueMethodFailsCall {
103+ return m .requeueMethodError
104+ }
105+ return nil
106+ }
107+
108+ func (m * OutboxMock ) LastMethod () string {
109+ return m .lastMethod
110+ }
0 commit comments