mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Refactor quota service (#58643)
Chore: Refactor quota service (#57586) * Chore: refactore quota service * Apply suggestions from code review
This commit is contained in:
committed by
GitHub
parent
dd0d034796
commit
9855e74b92
@@ -12,18 +12,46 @@ type FakeQuotaService struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func NewQuotaServiceFake() *FakeQuotaService {
|
||||
return &FakeQuotaService{}
|
||||
func New(reached bool, err error) *FakeQuotaService {
|
||||
return &FakeQuotaService{reached, err}
|
||||
}
|
||||
|
||||
func (f *FakeQuotaService) QuotaReached(c *models.ReqContext, target string) (bool, error) {
|
||||
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 *models.ReqContext, target quota.TargetSrv) (bool, error) {
|
||||
return f.reached, f.err
|
||||
}
|
||||
|
||||
func (f *FakeQuotaService) CheckQuotaReached(c context.Context, target string, params *quota.ScopeParameters) (bool, error) {
|
||||
func (f *FakeQuotaService) CheckQuotaReached(c context.Context, target quota.TargetSrv, params *quota.ScopeParameters) (bool, error) {
|
||||
return f.reached, f.err
|
||||
}
|
||||
|
||||
func (f *FakeQuotaService) DeleteByUser(c context.Context, userID int64) error {
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user