summaryrefslogtreecommitdiff
path: root/gocomplete/tests_test.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-07-28 15:20:25 +0300
committerGitHub <[email protected]>2017-07-28 15:20:25 +0300
commitc111db7af1861723f8143fac03496f0acf06295a (patch)
tree53ee725df252e8f71481a0ec26a846e2a76cf60b /gocomplete/tests_test.go
parente8d6fef54b6283f8bd3fbcb4a7de8884eb540293 (diff)
parenta67bb12457c4c976419760835140490b783ec9f0 (diff)
Merge pull request #44 from posener/package
gocomplete: Add support for system GOPATH packages
Diffstat (limited to 'gocomplete/tests_test.go')
-rw-r--r--gocomplete/tests_test.go37
1 files changed, 22 insertions, 15 deletions
diff --git a/gocomplete/tests_test.go b/gocomplete/tests_test.go
index 5683d24..6799157 100644
--- a/gocomplete/tests_test.go
+++ b/gocomplete/tests_test.go
@@ -12,15 +12,15 @@ func TestPredictions(t *testing.T) {
t.Parallel()
tests := []struct {
- name string
- predictor complete.Predictor
- last string
- completion []string
+ name string
+ predictor complete.Predictor
+ last string
+ want []string
}{
{
- name: "predict tests ok",
- predictor: predictTest,
- completion: []string{"TestPredictions", "Example"},
+ name: "predict tests ok",
+ predictor: predictTest,
+ want: []string{"TestPredictions", "Example"},
},
{
name: "predict tests not found",
@@ -28,9 +28,9 @@ func TestPredictions(t *testing.T) {
last: "X",
},
{
- name: "predict benchmark ok",
- predictor: predictBenchmark,
- completion: []string{"BenchmarkFake"},
+ name: "predict benchmark ok",
+ predictor: predictBenchmark,
+ want: []string{"BenchmarkFake"},
},
{
name: "predict benchmarks not found",
@@ -38,9 +38,16 @@ func TestPredictions(t *testing.T) {
last: "X",
},
{
- name: "predict packages ok",
- predictor: complete.PredictFunc(predictPackages),
- completion: []string{"./"},
+ name: "predict local ok",
+ predictor: complete.PredictFunc(predictPackages),
+ last: ".",
+ want: []string{"./"},
+ },
+ {
+ name: "predict system ok",
+ predictor: complete.PredictFunc(predictPackages),
+ last: "github.com/posener/complete/goc",
+ want: []string{"github.com/posener/complete/gocomplete/"},
},
{
name: "predict packages not found",
@@ -53,8 +60,8 @@ func TestPredictions(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
a := complete.Args{Last: tt.last}
got := tt.predictor.Predict(a)
- if want := tt.completion; !equal(got, want) {
- t.Errorf("Failed %s: completion = %q, want %q", t.Name(), got, want)
+ if !equal(got, tt.want) {
+ t.Errorf("Failed %s: got: %q, want: %q", t.Name(), got, tt.want)
}
})
}