mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
40 lines
764 B
Go
40 lines
764 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
// unit tests for internal functions
|
|
func TestIsAllowed(t *testing.T) {
|
|
cases := []struct {
|
|
requested []string
|
|
allowed []string
|
|
expected bool
|
|
}{
|
|
{
|
|
requested: []string{"a", "b", "c"},
|
|
allowed: []string{"a", "b", "c", "d", "e"},
|
|
expected: true,
|
|
},
|
|
{
|
|
requested: []string{"a", "b", "c", "f"},
|
|
allowed: []string{"a", "b", "c", "d", "e"},
|
|
expected: false,
|
|
},
|
|
{
|
|
requested: []string{"a", "b", "c"},
|
|
allowed: []string{},
|
|
expected: false,
|
|
},
|
|
}
|
|
|
|
for i, test := range cases {
|
|
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
|
if res := isAllowed(test.requested, test.allowed); res != test.expected {
|
|
t.Errorf("expected %v, got %v", test.expected, res)
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|