Skip to content

Commit cc5b17b

Browse files
committed
Add test for NewKey function
1 parent 79f87d8 commit cc5b17b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/assets_key_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,52 @@ func TestKeyJSON(t *testing.T) {
3939
t.FailNow()
4040
}
4141
}
42+
43+
func TestKeyGenUsingAssetType(t *testing.T) {
44+
m := map[string]interface{}{
45+
"@assetType": "person",
46+
"id": "31820792048",
47+
}
48+
49+
key, err := assets.NewKey(m)
50+
if err != nil {
51+
log.Println(err)
52+
t.FailNow()
53+
}
54+
55+
expectedKey := assets.Key{
56+
"@assetType": "person",
57+
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
58+
}
59+
60+
if !reflect.DeepEqual(key, expectedKey) {
61+
log.Println("these should be deeply equal")
62+
log.Println(key)
63+
log.Println(expectedKey)
64+
t.FailNow()
65+
}
66+
}
67+
68+
func TestKeyGenUsingKey(t *testing.T) {
69+
m := map[string]interface{}{
70+
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
71+
}
72+
73+
key, err := assets.NewKey(m)
74+
if err != nil {
75+
log.Println(err)
76+
t.FailNow()
77+
}
78+
79+
expectedKey := assets.Key{
80+
"@assetType": "person",
81+
"@key": "person:47061146-c642-51a1-844a-bf0b17cb5e19",
82+
}
83+
84+
if !reflect.DeepEqual(key, expectedKey) {
85+
log.Println("these should be deeply equal")
86+
log.Println(key)
87+
log.Println(expectedKey)
88+
t.FailNow()
89+
}
90+
}

0 commit comments

Comments
 (0)