зеркало из https://github.com/golang/dep.git
Update dep init CLI helptext; tweak tests a bit
This commit is contained in:
Родитель
bba3159e38
Коммит
7948c8a848
|
@ -26,9 +26,16 @@ manifest and lock files, and vendoring the dependencies. If root isn't
|
|||
specified, use the current directory.
|
||||
|
||||
The version of each dependency will reflect the current state of the GOPATH. If
|
||||
a dependency doesn't exist in the GOPATH, the network would be used to
|
||||
solve-for, and the solution will appear in manifest and lock. Solved
|
||||
dependencies will be vendored in vendor/ dir relative to project root.
|
||||
a dependency doesn't exist in the GOPATH, a version will be selected from the
|
||||
versions available from the upstream source per the following algorithm:
|
||||
|
||||
- Tags conforming to semver (sorted by semver rules)
|
||||
- Default branch(es) (sorted lexicographically)
|
||||
- Non-semver tags (sorted lexicographically)
|
||||
|
||||
A Gopkg.toml file will be written with inferred version constraints for all
|
||||
direct dependencies. Gopkg.lock will be written with precise versions, and
|
||||
vendor/ will be populated with the precise versions written to Gopkg.lock.
|
||||
`
|
||||
|
||||
func (cmd *initCommand) Name() string { return "init" }
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/sdboyer/gps"
|
||||
|
@ -39,9 +40,9 @@ func TestIsStdLib(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetProjectPropertiesFromVersion(t *testing.T) {
|
||||
wantSemver, _ := gps.NewSemverConstraint("^v1.0.0")
|
||||
cases := []struct {
|
||||
version gps.Version
|
||||
want gps.Version
|
||||
version, want gps.Constraint
|
||||
}{
|
||||
{
|
||||
version: gps.NewBranch("foo-branch"),
|
||||
|
@ -51,6 +52,10 @@ func TestGetProjectPropertiesFromVersion(t *testing.T) {
|
|||
version: gps.NewVersion("foo-version"),
|
||||
want: gps.NewVersion("foo-version"),
|
||||
},
|
||||
{
|
||||
version: gps.NewVersion("v1.0.0"),
|
||||
want: wantSemver,
|
||||
},
|
||||
{
|
||||
version: gps.NewBranch("foo-branch").Is("some-revision"),
|
||||
want: gps.NewBranch("foo-branch"),
|
||||
|
@ -63,20 +68,16 @@ func TestGetProjectPropertiesFromVersion(t *testing.T) {
|
|||
version: gps.Revision("some-revision"),
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
version: gps.NewVersion("v1.0.0").Is("some-revision"),
|
||||
want: wantSemver,
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
actualProp := getProjectPropertiesFromVersion(c.version)
|
||||
if c.want != actualProp.Constraint {
|
||||
t.Fatalf("Expected project property to be %v, got %v", actualProp.Constraint, c.want)
|
||||
actualProp := getProjectPropertiesFromVersion(c.version.(gps.Version))
|
||||
if !reflect.DeepEqual(c.want, actualProp.Constraint) {
|
||||
t.Fatalf("Constraints are not as expected: \n\t(GOT) %v\n\t(WNT) %v", actualProp.Constraint, c.want)
|
||||
}
|
||||
}
|
||||
|
||||
// Test to have caret in semver version
|
||||
outsemver := getProjectPropertiesFromVersion(gps.NewVersion("v1.0.0"))
|
||||
wantSemver, _ := gps.NewSemverConstraint("^1.0.0")
|
||||
|
||||
if outsemver.Constraint.String() != wantSemver.String() {
|
||||
t.Fatalf("Expected semver to be %v, got %v", outsemver.Constraint, wantSemver)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче