forked from gojek/weaver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl_test.go
46 lines (40 loc) · 786 Bytes
/
acl_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
38
39
40
41
42
43
44
45
46
package weaver
import (
"testing"
"github.com/stretchr/testify/assert"
)
const (
validACLDoc = `{
"id": "gojek_hello",
"criterion" : "Method('POST') && Path('/gojek/hello-service')",
"endpoint" : {
"shard_expr": ".serviceType",
"matcher": "body",
"shard_func": "lookup",
"shard_config": {
"999": {
"backend_name": "hello_backend",
"backend":"http://hello.golabs.io"
}
}
}
}`
)
var genACLTests = []struct {
aclDoc string
expectedErr error
}{
{
validACLDoc,
nil,
},
}
func TestGenACL(t *testing.T) {
acl := &ACL{}
for _, tt := range genACLTests {
actualErr := acl.GenACL(tt.aclDoc)
if actualErr != tt.expectedErr {
assert.Failf(t, "Unexpected error message", "want: %v got: %v", tt.expectedErr, actualErr)
}
}
}