3
0
Files
corteza/pkg/payload/util_test.go
Vivek Patel f160d391f5 Add filters to permissions for role route
It allows filtering for specific rules and also the rules which are applied to the resource, and not to a specific resource.

Introduces generic methods for RuleSet and FindRules method to access_control generation template.
2022-07-19 17:30:26 +05:30

51 lines
766 B
Go

package payload
import (
"github.com/cortezaproject/corteza-server/pkg/filter"
"github.com/stretchr/testify/require"
"testing"
)
func TestParseFilterState(t *testing.T) {
var (
req = require.New(t)
)
tests := []struct {
name string
input string
expected filter.State
}{
{
"invalid string should be Excluded",
"zero",
filter.StateExcluded,
},
{
"empty string should be Excluded",
"0",
filter.StateExcluded,
},
{
"Excluded",
"0",
filter.StateExcluded,
},
{
"Excluded",
"1",
filter.StateInclusive,
},
{
"Excluded",
"2",
filter.StateExclusive,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req.Equal(tt.expected, ParseFilterState(tt.input))
})
}
}