diff options
| author | Eyal Posener <[email protected]> | 2017-05-05 23:07:18 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-05 23:07:18 +0300 |
| commit | c8263230e11aa755d3b0b964d4bf7ff296661f5e (patch) | |
| tree | 257d6dfb9218ad536d3b20956b499f2b74ef271c /complete_test.go | |
| parent | 04d16f6064c7c71068f47b4e7106f15a05b6b326 (diff) | |
Add additional args
add predition of directories
add ability for prediction union
Diffstat (limited to 'complete_test.go')
| -rw-r--r-- | complete_test.go | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/complete_test.go b/complete_test.go index aad747e..a6daa98 100644 --- a/complete_test.go +++ b/complete_test.go @@ -27,12 +27,13 @@ func TestCompleter_Complete(t *testing.T) { "-flag2": PredictNothing, "-flag3": PredictNothing, }, + Args: PredictDirs("./tests/").Or(PredictFiles("./tests/*.md")), }, }, Flags: map[string]Predicate{ "-h": PredictNothing, "-global1": PredictAnything, - "-o": PredictFiles("./gocomplete/*.go"), + "-o": PredictFiles("./tests/*.txt"), }, }, } @@ -45,6 +46,8 @@ func TestCompleter_Complete(t *testing.T) { allGlobals = append(allGlobals, flag) } + testTXTFiles := []string{"./tests/a.txt", "./tests/b.txt", "./tests/c.txt"} + tests := []struct { args string want []string @@ -83,7 +86,19 @@ func TestCompleter_Complete(t *testing.T) { }, { args: "sub2 ", - want: []string{"-flag2", "-flag3", "-h", "-global1", "-o"}, + want: []string{"./tests", "-flag2", "-flag3", "-h", "-global1", "-o"}, + }, + { + args: "sub2 tests", + want: []string{"./tests", "./tests/readme.md", "./tests/dir"}, + }, + { + args: "sub2 tests/re", + want: []string{"./tests/readme.md"}, + }, + { + args: "sub2 -flag2 ", + want: []string{"./tests", "-flag2", "-flag3", "-h", "-global1", "-o"}, }, { args: "sub1 -fl", @@ -119,15 +134,31 @@ func TestCompleter_Complete(t *testing.T) { }, { args: "-o ", - want: []string{"./gocomplete/complete.go"}, + want: []string{}, + }, + { + args: "-o ./tes", + want: []string{}, + }, + { + args: "-o tests/", + want: testTXTFiles, + }, + { + args: "-o tests", + want: testTXTFiles, }, { - args: "-o goco", - want: []string{"./gocomplete/complete.go"}, + args: "-o ./compl", + want: []string{}, }, { - args: "-o ./goco", - want: []string{"./gocomplete/complete.go"}, + args: "-o ./complete.go", + want: []string{}, + }, + { + args: "-o ./complete.go ", + want: allGlobals, }, } |
