forked from CyCoreSystems/ari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkey_test.go
37 lines (29 loc) · 787 Bytes
/
key_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ari
import "testing"
func TestKeyMatch(t *testing.T) {
// two empty keys should match
ok := NewKey("", "").Match(NewKey("", ""))
if !ok {
t.Errorf("Two empty keys should match")
}
ok = AppKey("app").Match(NewKey("", ""))
if !ok {
t.Errorf("App key should match any subkey")
}
ok = AppKey("app").Match(AppKey("app2"))
if ok {
t.Errorf("Two separate app keys should not match")
}
ok = NodeKey("app", "node").Match(NewKey("", ""))
if !ok {
t.Errorf("Node key should match any subkey")
}
ok = NewKey("application", "id1").Match(NewKey("application", "id1"))
if !ok {
t.Errorf("Application/id1 should match")
}
ok = NewKey("application", "").Match(NewKey("application", "id1"))
if !ok {
t.Errorf("Application/* should match application/id")
}
}