-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add go linter - "unused" * use _ to name unused but needed padding variable * remove unused code * add queue test to appease unused linter * remove unused code in test * remove unused func * remove unused struct identified by linter * remove unused variable * remove unused code * remove unused file * remove unused struct * remove unused function * remove unused observe peers function in raft * remove unused declareFaults function * annotate nolint:unused on needed methods
- Loading branch information
Showing
18 changed files
with
68 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package ratelimit | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestQueue(t *testing.T) { | ||
const size = 3 | ||
q := &queue{buf: make([]int64, size)} | ||
|
||
if q.len() != 0 { | ||
t.Fatalf("q.len() = %d, expect 0", q.len()) | ||
} | ||
|
||
if q.cap() != size { | ||
t.Fatalf("q.cap() = %d, expect %d", q.cap(), size) | ||
} | ||
|
||
for i := int64(0); i < int64(size); i++ { | ||
err := q.push(i) | ||
if err != nil { | ||
t.Fatalf("cannot push element %d", i) | ||
} | ||
} | ||
|
||
if q.len() != size { | ||
t.Fatalf("q.len() = %d, expect %d", q.len(), size) | ||
} | ||
|
||
err := q.push(int64(size)) | ||
if err != ErrRateLimitExceeded { | ||
t.Fatalf("pushing element beyond capacity should have failed with err: %s, got %s", ErrRateLimitExceeded, err) | ||
} | ||
|
||
if q.front() != 0 { | ||
t.Fatalf("q.front() = %d, expect 0", q.front()) | ||
} | ||
|
||
if q.back() != int64(size-1) { | ||
t.Fatalf("q.back() = %d, expect %d", q.back(), size-1) | ||
} | ||
|
||
popVal := q.pop() | ||
if popVal != 0 { | ||
t.Fatalf("q.pop() = %d, expect 0", popVal) | ||
} | ||
|
||
if q.len() != size-1 { | ||
t.Fatalf("q.len() = %d, expect %d", q.len(), size-1) | ||
} | ||
|
||
// Testing truncation. | ||
threshold := int64(1) | ||
q.truncate(threshold) | ||
if q.len() != 1 { | ||
t.Fatalf("q.len() after truncate = %d, expect 1", q.len()) | ||
} | ||
if q.front() != 2 { | ||
t.Fatalf("q.front() after truncate = %d, expect 2", q.front()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.