[#4] limiting: Add check for duplicated keys
Some checks failed
DCO action / DCO (pull_request) Successful in 30s
Vulncheck / Vulncheck (pull_request) Failing after 40s
Tests and linters / Staticcheck (pull_request) Successful in 53s
Tests and linters / Run gofumpt (pull_request) Successful in 51s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m16s
Tests and linters / gopls check (pull_request) Successful in 1m13s
Tests and linters / Tests (pull_request) Successful in 47s
Tests and linters / Lint (pull_request) Successful in 1m29s
Tests and linters / Tests with -race (pull_request) Successful in 1m35s
Some checks failed
DCO action / DCO (pull_request) Successful in 30s
Vulncheck / Vulncheck (pull_request) Failing after 40s
Tests and linters / Staticcheck (pull_request) Successful in 53s
Tests and linters / Run gofumpt (pull_request) Successful in 51s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m16s
Tests and linters / gopls check (pull_request) Successful in 1m13s
Tests and linters / Tests (pull_request) Successful in 47s
Tests and linters / Lint (pull_request) Successful in 1m29s
Tests and linters / Tests with -race (pull_request) Successful in 1m35s
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
240501c1b7
commit
455fec9b99
2 changed files with 26 additions and 6 deletions
|
@ -24,6 +24,14 @@ type testKeyLimit struct {
|
|||
}
|
||||
|
||||
func TestLimiter(t *testing.T) {
|
||||
t.Run("duplicated keys", func(t *testing.T) {
|
||||
_, err := limiting.New([]limiting.KeyLimit{
|
||||
{[]string{"A", "B"}, 10},
|
||||
{[]string{"B", "C"}, 10},
|
||||
})
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
||||
testLimits := []*testKeyLimit{
|
||||
{keys: []string{"A"}, limit: operationCount / 4},
|
||||
{keys: []string{"B"}, limit: operationCount / 2},
|
||||
|
@ -44,7 +52,9 @@ func TestLimiter(t *testing.T) {
|
|||
}
|
||||
|
||||
func testLimiter(t *testing.T, testCases []*testKeyLimit, blocking bool) {
|
||||
lr := limiting.New(getLimits(testCases))
|
||||
lr, err := limiting.New(getLimits(testCases))
|
||||
require.NoError(t, err)
|
||||
|
||||
tasks := createTestTasks(testCases, lr, blocking)
|
||||
|
||||
t.Run("first run", func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue