-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
variable_service.go
71 lines (60 loc) · 2.9 KB
/
variable_service.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
package mock
import (
"context"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
)
var _ influxdb.VariableService = &VariableService{}
type VariableService struct {
CreateVariableF func(context.Context, *influxdb.Variable) error
CreateVariableCalls SafeCount
DeleteVariableF func(context.Context, platform.ID) error
DeleteVariableCalls SafeCount
FindVariableByIDF func(context.Context, platform.ID) (*influxdb.Variable, error)
FindVariableByIDCalls SafeCount
FindVariablesF func(context.Context, influxdb.VariableFilter, ...influxdb.FindOptions) ([]*influxdb.Variable, error)
FindVariablesCalls SafeCount
ReplaceVariableF func(context.Context, *influxdb.Variable) error
ReplaceVariableCalls SafeCount
UpdateVariableF func(ctx context.Context, id platform.ID, update *influxdb.VariableUpdate) (*influxdb.Variable, error)
UpdateVariableCalls SafeCount
}
// NewVariableService returns a mock of VariableService where its methods will return zero values.
func NewVariableService() *VariableService {
return &VariableService{
CreateVariableF: func(context.Context, *influxdb.Variable) error { return nil },
DeleteVariableF: func(context.Context, platform.ID) error { return nil },
FindVariableByIDF: func(context.Context, platform.ID) (*influxdb.Variable, error) { return nil, nil },
FindVariablesF: func(context.Context, influxdb.VariableFilter, ...influxdb.FindOptions) ([]*influxdb.Variable, error) {
return nil, nil
},
ReplaceVariableF: func(context.Context, *influxdb.Variable) error { return nil },
UpdateVariableF: func(ctx context.Context, id platform.ID, update *influxdb.VariableUpdate) (*influxdb.Variable, error) {
return nil, nil
},
}
}
func (s *VariableService) CreateVariable(ctx context.Context, variable *influxdb.Variable) error {
defer s.CreateVariableCalls.IncrFn()()
return s.CreateVariableF(ctx, variable)
}
func (s *VariableService) ReplaceVariable(ctx context.Context, variable *influxdb.Variable) error {
defer s.ReplaceVariableCalls.IncrFn()()
return s.ReplaceVariableF(ctx, variable)
}
func (s *VariableService) FindVariables(ctx context.Context, filter influxdb.VariableFilter, opts ...influxdb.FindOptions) ([]*influxdb.Variable, error) {
defer s.FindVariablesCalls.IncrFn()()
return s.FindVariablesF(ctx, filter, opts...)
}
func (s *VariableService) FindVariableByID(ctx context.Context, id platform.ID) (*influxdb.Variable, error) {
defer s.FindVariableByIDCalls.IncrFn()()
return s.FindVariableByIDF(ctx, id)
}
func (s *VariableService) DeleteVariable(ctx context.Context, id platform.ID) error {
defer s.DeleteVariableCalls.IncrFn()()
return s.DeleteVariableF(ctx, id)
}
func (s *VariableService) UpdateVariable(ctx context.Context, id platform.ID, update *influxdb.VariableUpdate) (*influxdb.Variable, error) {
defer s.UpdateVariableCalls.IncrFn()()
return s.UpdateVariableF(ctx, id, update)
}