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

Add importer for github.com/LK4D4/vndr #978

Merged
merged 7 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add check of manifest and lock contents
  • Loading branch information
spenczar committed Aug 8, 2017
commit cbb749f2a3e309706b74593252059a5fc0e8f44a
2 changes: 1 addition & 1 deletion cmd/dep/vndr_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (v *vndrImporter) Import(dir string, pr gps.ProjectRoot) (*dep.Manifest, *d

lp := gps.NewLockedProject(pc.Ident, version, nil)

lock.P = append(lock.P)
lock.P = append(lock.P, lp)
fb.NewLockedProjectFeedback(lp, fb.DepTypeImported).LogFeedback(v.logger)
}

Expand Down
64 changes: 43 additions & 21 deletions cmd/dep/vndr_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"bytes"
"log"
"path/filepath"
"reflect"
"testing"

"github.com/golang/dep"
"github.com/golang/dep/internal/gps"
"github.com/golang/dep/internal/test"
"github.com/pkg/errors"
)
Expand All @@ -35,29 +38,48 @@ func TestVndrConfig_Import(t *testing.T) {
t.Fatal("Expected the importer to detect vndr configuration file")
}

// m, l, err := v.Import(projectRoot, testProjectRoot)
_, _, err = v.Import(projectRoot, testProjectRoot)
m, l, err := v.Import(projectRoot, testProjectRoot)
h.Must(err)

// if m == nil {
// t.Error("expected manifest to be generated")
// } else {
// if len(m.Constraints) != 2 {
// t.Errorf("expected 2 constraints in manifest, have %+v", m.Constraints)
// } else {
// p1, ok := m.Constraints[gps.ProjectRoot("github.com/sdboyer/deptest")]
// if !ok {
// t.Errorf("expected constraint to for github.com/sdboyer/deptest, have %+v", m.Constraints)
// } else {
// if want := "https://github.com/sdboyer/deptest"; p1.Source != want {
// t.Errorf("unexpected source, have=%v, want=%v", p1.Source, want)
// }
// if want := "3f4c3bea144e112a69bbe5d8d01c1b09a544253f", p1.Constraint.String() != want {
// t.Errorf("unexpected constraint, have=%v, want=%v", p1.Constraint.String(), want)
// }
// }
// }
// }
constraint, err := gps.NewSemverConstraint("^2.0.0")
h.Must(err)
wantM := &dep.Manifest{
Constraints: gps.ProjectConstraints{
"github.com/sdboyer/deptest": gps.ProjectProperties{
Source: "https://github.com/sdboyer/deptest.git",
Constraint: gps.Revision("3f4c3bea144e112a69bbe5d8d01c1b09a544253f"),
},
"github.com/sdboyer/deptestdos": gps.ProjectProperties{
Constraint: constraint,
},
},
}
if !reflect.DeepEqual(wantM, m) {
t.Errorf("unexpected manifest\nhave=%+v\nwant=%+v", m, wantM)
}

wantL := &dep.Lock{
P: []gps.LockedProject{
gps.NewLockedProject(
gps.ProjectIdentifier{
ProjectRoot: "github.com/sdboyer/deptest",
Source: "https://github.com/sdboyer/deptest.git",
},
gps.NewVersion("v0.8.1").Pair(gps.Revision("3f4c3bea144e112a69bbe5d8d01c1b09a544253f")),
nil,
),
gps.NewLockedProject(
gps.ProjectIdentifier{
ProjectRoot: "github.com/sdboyer/deptestdos",
},
gps.Revision("v2.0.0"),
nil,
),
},
}
if !reflect.DeepEqual(wantL, l) {
t.Errorf("unexpected lock\nhave=%+v\nwant=%+v", l, wantL)
}

goldenFile := "vndr/golden.txt"
got := logOutput.String()
Expand Down