Return nil instead of empty list when returning a PermissionDenied error, updated unit test

This commit is contained in:
Preetha Appan 2017-07-31 17:23:20 -05:00
parent da29b74d03
commit 307049e17f
2 changed files with 3 additions and 4 deletions

View File

@ -26,7 +26,7 @@ func FilterDirEnt(acl acl.ACL, ent structs.DirEntries) (structs.DirEntries, erro
df := dirEntFilter{acl: acl, ent: ent} df := dirEntFilter{acl: acl, ent: ent}
filtered := ent[:FilterEntries(&df)] filtered := ent[:FilterEntries(&df)]
if len(filtered) == 0 { if len(filtered) == 0 {
return filtered, errPermissionDenied return nil, errPermissionDenied
} }
return filtered, nil return filtered, nil
} }
@ -53,7 +53,7 @@ func FilterKeys(acl acl.ACL, keys []string) ([]string, error) {
kf := keyFilter{acl: acl, keys: keys} kf := keyFilter{acl: acl, keys: keys}
filteredKeys := keys[:FilterEntries(&kf)] filteredKeys := keys[:FilterEntries(&kf)]
if len(filteredKeys) == 0 { if len(filteredKeys) == 0 {
return filteredKeys, errPermissionDenied return nil, errPermissionDenied
} }
return filteredKeys, nil return filteredKeys, nil
} }
@ -85,7 +85,7 @@ func FilterTxnResults(acl acl.ACL, results structs.TxnResults) (structs.TxnResul
rf := txnResultsFilter{acl: acl, results: results} rf := txnResultsFilter{acl: acl, results: results}
filtered := results[:FilterEntries(&rf)] filtered := results[:FilterEntries(&rf)]
if len(filtered) == 0 { if len(filtered) == 0 {
return filtered, errPermissionDenied return nil, errPermissionDenied
} }
return filtered, nil return filtered, nil
} }

View File

@ -72,7 +72,6 @@ func TestFilter_Keys(t *testing.T) {
}, },
tcase{ tcase{
in: []string{"abe", "lincoln"}, in: []string{"abe", "lincoln"},
out: []string{},
err: errPermissionDenied, err: errPermissionDenied,
}, },
tcase{ tcase{