summaryrefslogtreecommitdiff
path: root/pkg/stringid/stringid_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/stringid/stringid_test.go')
-rw-r--r--pkg/stringid/stringid_test.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/pkg/stringid/stringid_test.go b/pkg/stringid/stringid_test.go
index 2660d2e65f..e2d0d7906f 100644
--- a/pkg/stringid/stringid_test.go
+++ b/pkg/stringid/stringid_test.go
@@ -8,7 +8,7 @@ import (
func TestGenerateRandomID(t *testing.T) {
id := GenerateRandomID()
- if len(id) != 64 {
+ if len(id) != fullLen {
t.Fatalf("Id returned is incorrect: %s", id)
}
}
@@ -62,3 +62,28 @@ func TestIsShortIDNotCorrectSize(t *testing.T) {
t.Fatalf("%s is not a short ID", id)
}
}
+
+var testIDs = []string{
+ "4e38e38c8ce0",
+ strings.Repeat("a", shortLen+1),
+ strings.Repeat("a", 16000),
+ "90435eec5c4e124e741ef731e118be2fc799a68aba0466ec17717f24ce2ae6a2",
+}
+
+func BenchmarkIsShortID(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ for _, id := range testIDs {
+ _ = IsShortID(id)
+ }
+ }
+}
+
+func BenchmarkValidateID(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ for _, id := range testIDs {
+ _ = ValidateID(id)
+ }
+ }
+}