Skip to content

Commit dad97e4

Browse files
palash25rShetty
authored andcommitted
ACL: Add tests (#22)
Related to: #20
1 parent 9295547 commit dad97e4

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

acl_test.go

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package weaver
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
const (
10+
validACLDoc = `{
11+
"id": "gojek_hello",
12+
"criterion" : "Method('POST') && Path('/gojek/hello-service')",
13+
"endpoint" : {
14+
"shard_expr": ".serviceType",
15+
"matcher": "body",
16+
"shard_func": "lookup",
17+
"shard_config": {
18+
"999": {
19+
"backend_name": "hello_backend",
20+
"backend":"http://hello.golabs.io"
21+
}
22+
}
23+
}
24+
}`
25+
)
26+
27+
var genACLTests = []struct {
28+
aclDoc string
29+
expectedErr error
30+
}{
31+
{
32+
validACLDoc,
33+
nil,
34+
},
35+
}
36+
37+
func TestGenACL(t *testing.T) {
38+
acl := &ACL{}
39+
40+
for _, tt := range genACLTests {
41+
actualErr := acl.GenACL(tt.aclDoc)
42+
if actualErr != tt.expectedErr {
43+
assert.Failf(t, "Unexpected error message", "want: %v got: %v", tt.expectedErr, actualErr)
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)