1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package transaction
import (
"context"
"errors"
"gitlab.com/gitlab-org/gitaly/internal/transaction/txinfo"
"gitlab.com/gitlab-org/gitaly/internal/transaction/voting"
)
// MockManager is a mock Manager for use in tests.
type MockManager struct {
VoteFn func(context.Context, txinfo.Transaction, txinfo.PraefectServer, voting.Vote) error
StopFn func(context.Context, txinfo.Transaction, txinfo.PraefectServer) error
}
// Vote calls the MockManager's Vote function, if set. Otherwise, it returns an error.
func (m *MockManager) Vote(ctx context.Context, tx txinfo.Transaction, praefect txinfo.PraefectServer, vote voting.Vote) error {
if m.VoteFn == nil {
return errors.New("mock does not implement Vote function")
}
return m.VoteFn(ctx, tx, praefect, vote)
}
// Stop calls the MockManager's Stop function, if set. Otherwise, it returns an error.
func (m *MockManager) Stop(ctx context.Context, tx txinfo.Transaction, praefect txinfo.PraefectServer) error {
if m.StopFn == nil {
return errors.New("mock does not implement Stop function")
}
return m.StopFn(ctx, tx, praefect)
}
|