forked from joncrlsn/pgdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrant_test.go
More file actions
25 lines (22 loc) · 739 Bytes
/
grant_test.go
File metadata and controls
25 lines (22 loc) · 739 Bytes
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
package main
import (
"fmt"
"testing"
)
func Test_parseAcls(t *testing.T) {
doParseAcls(t, "user1=rwa/c42", "user1", 3)
doParseAcls(t, "=arwdDxt/c42", "public", 7) // first of two lines
doParseAcls(t, "u3=rwad/postgres", "u3", 4) // second of two lines
doParseAcls(t, "user2=arwxt/postgres", "user2", 5)
doParseAcls(t, "", "", 0)
}
func doParseAcls(t *testing.T, acl string, expectedRole string, expectedPermCount int) {
fmt.Println("Testing", acl)
role, perms := parseAcl(acl)
if role != expectedRole {
t.Error("Wrong role parsed: " + role + " instead of " + expectedRole)
}
if len(perms) != expectedPermCount {
t.Errorf("Incorrect number of permissions parsed: %d instead of %d", len(perms), expectedPermCount)
}
}