Refactor pkg/common, Fixes #11599
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
6a6ba3da1d
commit
4dd569ee0f
7 changed files with 97 additions and 60 deletions
35
stringid/stringid_test.go
Normal file
35
stringid/stringid_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package stringid
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGenerateRandomID(t *testing.T) {
|
||||
id := GenerateRandomID()
|
||||
|
||||
if len(id) != 64 {
|
||||
t.Fatalf("Id returned is incorrect: %s", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenId(t *testing.T) {
|
||||
id := GenerateRandomID()
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) != 12 {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenIdEmpty(t *testing.T) {
|
||||
id := ""
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) > len(id) {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenIdInvalid(t *testing.T) {
|
||||
id := "1234"
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) != len(id) {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue