-
Notifications
You must be signed in to change notification settings - Fork 15
/
interface.go
85 lines (72 loc) · 2.23 KB
/
interface.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//nolint:forcetypeassert
package schedule
import (
"context"
"github.com/data-preservation-programs/singularity/model"
"github.com/stretchr/testify/mock"
"github.com/ybbus/jsonrpc/v3"
"gorm.io/gorm"
)
type Handler interface {
CreateHandler(
ctx context.Context,
db *gorm.DB,
lotusClient jsonrpc.RPCClient,
request CreateRequest,
) (*model.Schedule, error)
UpdateHandler(
ctx context.Context,
db *gorm.DB,
scheduleID uint32,
request UpdateRequest,
) (*model.Schedule, error)
ListHandler(
ctx context.Context,
db *gorm.DB,
) ([]model.Schedule, error)
PauseHandler(
ctx context.Context,
db *gorm.DB,
scheduleID uint32,
) (*model.Schedule, error)
RemoveHandler(
ctx context.Context,
db *gorm.DB,
scheduleID uint32,
) error
ResumeHandler(
ctx context.Context,
db *gorm.DB,
scheduleID uint32,
) (*model.Schedule, error)
}
type DefaultHandler struct{}
var Default Handler = &DefaultHandler{}
var _ Handler = &MockSchedule{}
type MockSchedule struct {
mock.Mock
}
func (m *MockSchedule) RemoveHandler(ctx context.Context, db *gorm.DB, scheduleID uint32) error {
args := m.Called(ctx, db, scheduleID)
return args.Error(0)
}
func (m *MockSchedule) UpdateHandler(ctx context.Context, db *gorm.DB, scheduleID uint32, request UpdateRequest) (*model.Schedule, error) {
args := m.Called(ctx, db, scheduleID, request)
return args.Get(0).(*model.Schedule), args.Error(1)
}
func (m *MockSchedule) CreateHandler(ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, request CreateRequest) (*model.Schedule, error) {
args := m.Called(ctx, db, lotusClient, request)
return args.Get(0).(*model.Schedule), args.Error(1)
}
func (m *MockSchedule) ListHandler(ctx context.Context, db *gorm.DB) ([]model.Schedule, error) {
args := m.Called(ctx, db)
return args.Get(0).([]model.Schedule), args.Error(1)
}
func (m *MockSchedule) PauseHandler(ctx context.Context, db *gorm.DB, scheduleID uint32) (*model.Schedule, error) {
args := m.Called(ctx, db, scheduleID)
return args.Get(0).(*model.Schedule), args.Error(1)
}
func (m *MockSchedule) ResumeHandler(ctx context.Context, db *gorm.DB, scheduleID uint32) (*model.Schedule, error) {
args := m.Called(ctx, db, scheduleID)
return args.Get(0).(*model.Schedule), args.Error(1)
}