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

Commit

Permalink
enable constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Jun 14, 2017
1 parent 8e38cef commit f31346a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
7 changes: 6 additions & 1 deletion cmd/dep/gom_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,13 @@ func (g *gomImporter) convert(pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock, err
feedback(version, pi.ProjectRoot, fb.DepTypeImported, g.logger)
lp := gps.NewLockedProject(pi, version, nil)
lock.P = append(lock.P, lp)

pc.Constraint, err = deduceConstraint(rev, pc.Ident, g.sm)
if err != nil {
return nil, nil, err
}
}
manifest.Constraints[pc.Ident.ProjectRoot] = gps.ProjectProperties{Source: pc.Ident.Source, Constraint: nil}
manifest.Constraints[pc.Ident.ProjectRoot] = gps.ProjectProperties{Source: pc.Ident.Source, Constraint: pc.Constraint}
}

return manifest, lock, nil
Expand Down
26 changes: 15 additions & 11 deletions cmd/dep/gom_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ func TestGomConfig_ConvertProject(t *testing.T) {
t.Fatal(err)
}

_, ok := manifest.Constraints["github.com/sdboyer/deptest"]
d, ok := manifest.Constraints["github.com/sdboyer/deptest"]
if !ok {
t.Fatal("Expected the manifest to have a dependency for 'github.com/sdboyer/deptest' but got none")
}

v := d.Constraint.String()
if v != "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" {
t.Fatalf("Expected manifest constraint to be %q got %q", "ff2948a2ac8f538c4ecd55962e919d1e13e74baf", v)
}

p := lock.P[0]
if p.Ident().ProjectRoot != "github.com/sdboyer/deptest" {
t.Fatalf("Expected the lock to have a project for 'github.com/sdboyer/deptest' but got '%s'", p.Ident().ProjectRoot)
Expand Down Expand Up @@ -129,7 +134,7 @@ func TestGomConfig_ConvertProject_EmptyComment(t *testing.T) {
{
name: "github.com/sdboyer/deptest",
options: map[string]interface{}{
"commit": "ff2948a2ac8f538c4ecd55962e919d1e13e74baf",
"branch": "0.8.0",
},
},
}
Expand All @@ -139,24 +144,23 @@ func TestGomConfig_ConvertProject_EmptyComment(t *testing.T) {
t.Fatal(err)
}

_, ok := manifest.Constraints["github.com/sdboyer/deptest"]
d, ok := manifest.Constraints["github.com/sdboyer/deptest"]
if !ok {
t.Fatal("Expected the manifest to have a dependency for 'github.com/sdboyer/deptest' but got none")
}

v := d.Constraint.String()
if v != "^0.8.0" {
t.Fatalf("Expected manifest constraint to be %q got %q", "^0.8.0", v)
}

p := lock.P[0]
if p.Ident().ProjectRoot != "github.com/sdboyer/deptest" {
t.Fatalf("Expected the lock to have a project for 'github.com/sdboyer/deptest' but got '%s'", p.Ident().ProjectRoot)
}

lv := p.Version()
lpv, ok := lv.(gps.PairedVersion)
if !ok {
t.Fatalf("Expected locked version to be PairedVersion but got %T", lv)
}

rev := lpv.Underlying()
if rev != "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" {
rev := p.Version().String()
if rev != "0.8.0" {
t.Fatalf("Expected locked revision to be 'ff2948a2ac8f538c4ecd55962e919d1e13e74baf', got %s", rev)
}
}
Expand Down

0 comments on commit f31346a

Please sign in to comment.