|
@@ -13,10 +13,26 @@ func TestGenerateRandomID(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestGenerateNonCryptoID(t *testing.T) {
|
|
|
+ id := GenerateNonCryptoID()
|
|
|
+
|
|
|
+ if len(id) != 64 {
|
|
|
+ t.Fatalf("Id returned is incorrect: %s", id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestShortenId(t *testing.T) {
|
|
|
- id := GenerateRandomID()
|
|
|
+ id := "90435eec5c4e124e741ef731e118be2fc799a68aba0466ec17717f24ce2ae6a2"
|
|
|
+ truncID := TruncateID(id)
|
|
|
+ if truncID != "90435eec5c4e" {
|
|
|
+ t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestShortenSha256Id(t *testing.T) {
|
|
|
+ id := "sha256:4e38e38c8ce0b8d9041a9c4fefe786631d1416225e13b0bfe8cfa2321aec4bba"
|
|
|
truncID := TruncateID(id)
|
|
|
- if len(truncID) != 12 {
|
|
|
+ if truncID != "4e38e38c8ce0" {
|
|
|
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
|
|
}
|
|
|
}
|