Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 8378018

Browse files
committed
Add a test for ignored packages
1 parent f02730a commit 8378018

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

cmd/dep/govendor_importer_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"bytes"
99
"log"
1010
"path/filepath"
11+
"strings"
1112
"testing"
1213

1314
"github.com/golang/dep/internal/gps"
@@ -190,6 +191,37 @@ func TestGovendorConfig_Convert_TestProject(t *testing.T) {
190191
}
191192
}
192193

194+
func TestGovendorConfig_Convert_Ignore(t *testing.T) {
195+
h := test.NewHelper(t)
196+
defer h.Cleanup()
197+
198+
ctx := newTestContext(h)
199+
sm, err := ctx.SourceManager()
200+
h.Must(err)
201+
defer sm.Release()
202+
203+
pkg := "github.com/sdboyer/deptest"
204+
205+
g := newGovendorImporter(ctx.Err, true, sm)
206+
g.file = govendorFile{
207+
Ignore: strings.Join([]string{"test", pkg, "linux_amd64", "github.com/sdboyer/"}, " "),
208+
}
209+
210+
m, _, err := g.convert(testGovendorProjectRoot)
211+
if err != nil {
212+
t.Fatal(err)
213+
}
214+
215+
if len(m.Ignored) != 1 {
216+
t.Fatalf("Expected the ignored list to contain 1 project but got %d", len(m.Ignored))
217+
}
218+
219+
p := m.Ignored[0]
220+
if p != pkg {
221+
t.Fatalf("Expected the ignored list to have an element for %s but got '%s'", pkg, p)
222+
}
223+
}
224+
193225
func TestGovendorConfig_Convert_BadInput_EmptyPackagePath(t *testing.T) {
194226
h := test.NewHelper(t)
195227
defer h.Cleanup()

0 commit comments

Comments
 (0)