mirror of https://github.com/grafana/grafana
Alerting: Provisioning API respects global rule quota (#52180)
* Inject interface for quota service and create mock * Check quota and return 403 if limit exceeded * Implement tests for quota being exceededpull/52147/head^2
parent
eb5a96eae9
commit
2d7389c34d
@ -0,0 +1,81 @@ |
|||||||
|
// Code generated by mockery v2.12.0. DO NOT EDIT.
|
||||||
|
|
||||||
|
package provisioning |
||||||
|
|
||||||
|
import ( |
||||||
|
context "context" |
||||||
|
|
||||||
|
quota "github.com/grafana/grafana/pkg/services/quota" |
||||||
|
mock "github.com/stretchr/testify/mock" |
||||||
|
|
||||||
|
testing "testing" |
||||||
|
) |
||||||
|
|
||||||
|
// MockQuotaChecker is an autogenerated mock type for the QuotaChecker type
|
||||||
|
type MockQuotaChecker struct { |
||||||
|
mock.Mock |
||||||
|
} |
||||||
|
|
||||||
|
type MockQuotaChecker_Expecter struct { |
||||||
|
mock *mock.Mock |
||||||
|
} |
||||||
|
|
||||||
|
func (_m *MockQuotaChecker) EXPECT() *MockQuotaChecker_Expecter { |
||||||
|
return &MockQuotaChecker_Expecter{mock: &_m.Mock} |
||||||
|
} |
||||||
|
|
||||||
|
// CheckQuotaReached provides a mock function with given fields: ctx, target, scopeParams
|
||||||
|
func (_m *MockQuotaChecker) CheckQuotaReached(ctx context.Context, target string, scopeParams *quota.ScopeParameters) (bool, error) { |
||||||
|
ret := _m.Called(ctx, target, scopeParams) |
||||||
|
|
||||||
|
var r0 bool |
||||||
|
if rf, ok := ret.Get(0).(func(context.Context, string, *quota.ScopeParameters) bool); ok { |
||||||
|
r0 = rf(ctx, target, scopeParams) |
||||||
|
} else { |
||||||
|
r0 = ret.Get(0).(bool) |
||||||
|
} |
||||||
|
|
||||||
|
var r1 error |
||||||
|
if rf, ok := ret.Get(1).(func(context.Context, string, *quota.ScopeParameters) error); ok { |
||||||
|
r1 = rf(ctx, target, scopeParams) |
||||||
|
} else { |
||||||
|
r1 = ret.Error(1) |
||||||
|
} |
||||||
|
|
||||||
|
return r0, r1 |
||||||
|
} |
||||||
|
|
||||||
|
// MockQuotaChecker_CheckQuotaReached_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckQuotaReached'
|
||||||
|
type MockQuotaChecker_CheckQuotaReached_Call struct { |
||||||
|
*mock.Call |
||||||
|
} |
||||||
|
|
||||||
|
// CheckQuotaReached is a helper method to define mock.On call
|
||||||
|
// - ctx context.Context
|
||||||
|
// - target string
|
||||||
|
// - scopeParams *quota.ScopeParameters
|
||||||
|
func (_e *MockQuotaChecker_Expecter) CheckQuotaReached(ctx interface{}, target interface{}, scopeParams interface{}) *MockQuotaChecker_CheckQuotaReached_Call { |
||||||
|
return &MockQuotaChecker_CheckQuotaReached_Call{Call: _e.mock.On("CheckQuotaReached", ctx, target, scopeParams)} |
||||||
|
} |
||||||
|
|
||||||
|
func (_c *MockQuotaChecker_CheckQuotaReached_Call) Run(run func(ctx context.Context, target string, scopeParams *quota.ScopeParameters)) *MockQuotaChecker_CheckQuotaReached_Call { |
||||||
|
_c.Call.Run(func(args mock.Arguments) { |
||||||
|
run(args[0].(context.Context), args[1].(string), args[2].(*quota.ScopeParameters)) |
||||||
|
}) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
func (_c *MockQuotaChecker_CheckQuotaReached_Call) Return(_a0 bool, _a1 error) *MockQuotaChecker_CheckQuotaReached_Call { |
||||||
|
_c.Call.Return(_a0, _a1) |
||||||
|
return _c |
||||||
|
} |
||||||
|
|
||||||
|
// NewMockQuotaChecker creates a new instance of MockQuotaChecker. It also registers the testing.TB interface on the mock and a cleanup function to assert the mocks expectations.
|
||||||
|
func NewMockQuotaChecker(t testing.TB) *MockQuotaChecker { |
||||||
|
mock := &MockQuotaChecker{} |
||||||
|
mock.Mock.Test(t) |
||||||
|
|
||||||
|
t.Cleanup(func() { mock.AssertExpectations(t) }) |
||||||
|
|
||||||
|
return mock |
||||||
|
} |
||||||
Loading…
Reference in new issue