sq/libsq/source/internal_test.go
Neil O'Toole 26f0c9a381
Refactor source.Files (#363)
* Moved `source.Files` to its own package, thus the type is now `files.Files`.
* Moved much of the location functionality from pkg `source` to its own package `location`.
2024-01-24 23:29:55 -07:00

37 lines
749 B
Go

package source
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/neilotoole/sq/testh/tu"
)
func TestGroupsFilterOnlyDirectChildren(t *testing.T) {
testCases := []struct {
parent string
groups []string
want []string
}{
{
parent: "/",
groups: []string{"/", "prod", "prod/customer", "staging"},
want: []string{"prod", "staging"},
},
{
parent: "prod",
groups: []string{"/", "prod", "prod/customer", "prod/backup", "staging"},
want: []string{"prod/customer", "prod/backup"},
},
}
for i, tc := range testCases {
tc := tc
t.Run(tu.Name(i, tc.want), func(t *testing.T) {
got := groupsFilterOnlyDirectChildren(tc.parent, tc.groups)
require.EqualValues(t, tc.want, got)
})
}
}