forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfake.go
57 lines (43 loc) · 1.47 KB
/
fake.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
package quotatest
import (
"context"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/quota"
)
type FakeQuotaService struct {
reached bool
err error
}
func New(reached bool, err error) *FakeQuotaService {
return &FakeQuotaService{reached, err}
}
func (f *FakeQuotaService) GetQuotasByScope(ctx context.Context, scope quota.Scope, id int64) ([]quota.QuotaDTO, error) {
return []quota.QuotaDTO{}, nil
}
func (f *FakeQuotaService) Update(ctx context.Context, cmd *quota.UpdateQuotaCmd) error {
return nil
}
func (f *FakeQuotaService) QuotaReached(c *contextmodel.ReqContext, target quota.TargetSrv) (bool, error) {
return f.reached, f.err
}
func (f *FakeQuotaService) CheckQuotaReached(c context.Context, target quota.TargetSrv, params *quota.ScopeParameters) (bool, error) {
return f.reached, f.err
}
func (f *FakeQuotaService) DeleteQuotaForUser(c context.Context, userID int64) error {
return f.err
}
func (f *FakeQuotaService) RegisterQuotaReporter(e *quota.NewUsageReporter) error {
return f.err
}
type FakeQuotaStore struct {
ExpectedError error
}
func (f *FakeQuotaStore) DeleteByUser(ctx quota.Context, userID int64) error {
return f.ExpectedError
}
func (f *FakeQuotaStore) Get(ctx quota.Context, scopeParams *quota.ScopeParameters) (*quota.Map, error) {
return nil, f.ExpectedError
}
func (f *FakeQuotaStore) Update(ctx quota.Context, cmd *quota.UpdateQuotaCmd) error {
return f.ExpectedError
}