mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 05:31:38 +03:00
26f0c9a381
* 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`.
37 lines
749 B
Go
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)
|
|
})
|
|
}
|
|
}
|