mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 21:52:28 +03:00
33 lines
567 B
Go
33 lines
567 B
Go
|
package ast
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestExtractHandles(t *testing.T) {
|
||
|
testCases := []struct {
|
||
|
input string
|
||
|
want []string
|
||
|
}{
|
||
|
{
|
||
|
input: "@sakila | .actor",
|
||
|
want: []string{"@sakila"},
|
||
|
},
|
||
|
{
|
||
|
input: "@sakila_pg | .actor | join(@sakila_ms.film_actor, .actor_id)",
|
||
|
want: []string{"@sakila_ms", "@sakila_pg"},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, tc := range testCases {
|
||
|
tc := tc
|
||
|
t.Run(tc.input, func(t *testing.T) {
|
||
|
a := mustParse(t, tc.input)
|
||
|
got := ExtractHandles(a)
|
||
|
require.Equal(t, tc.want, got)
|
||
|
})
|
||
|
}
|
||
|
}
|