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

Commit 7a91b79

Browse files
authored
Merge pull request #489 from sdboyer/new-ensure
Implement new spec for `dep ensure`
2 parents c1aba4d + b8f7027 commit 7a91b79

File tree

146 files changed

+1815
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+1815
-232
lines changed

cmd/dep/ensure.go

+496-99
Large diffs are not rendered by default.

cmd/dep/ensure_test.go

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"testing"
9+
10+
"github.com/golang/dep/internal/gps"
11+
)
12+
13+
func TestInvalidEnsureFlagCombinations(t *testing.T) {
14+
ec := &ensureCommand{
15+
update: true,
16+
add: true,
17+
}
18+
19+
if err := ec.validateFlags(); err == nil {
20+
t.Error("-add and -update together should fail validation")
21+
}
22+
23+
ec.vendorOnly, ec.add = true, false
24+
if err := ec.validateFlags(); err == nil {
25+
t.Error("-vendor-only with -update should fail validation")
26+
}
27+
28+
ec.add, ec.update = true, false
29+
if err := ec.validateFlags(); err == nil {
30+
t.Error("-vendor-only with -add should fail validation")
31+
}
32+
33+
ec.noVendor, ec.add = true, false
34+
if err := ec.validateFlags(); err == nil {
35+
t.Error("-vendor-only with -no-vendor should fail validation")
36+
}
37+
ec.noVendor = false
38+
39+
// Also verify that the plain ensure path takes no args. This is a shady
40+
// test, as lots of other things COULD return errors, and we don't check
41+
// anything other than the error being non-nil. For now, it works well
42+
// because a panic will quickly result if the initial arg length validation
43+
// checks are incorrectly handled.
44+
if err := ec.runDefault(nil, []string{"foo"}, nil, nil, gps.SolveParameters{}); err == nil {
45+
t.Errorf("no args to plain ensure with -vendor-only")
46+
}
47+
ec.vendorOnly = false
48+
if err := ec.runDefault(nil, []string{"foo"}, nil, nil, gps.SolveParameters{}); err == nil {
49+
t.Errorf("no args to plain ensure")
50+
}
51+
}

cmd/dep/testdata/harness_tests/ensure/add/all-new-double-spec/final/Gopkg.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
[[constraint]]
3+
branch = "master"
4+
name = "github.com/sdboyer/deptesttres"
5+
6+
[[constraint]]
7+
name = "github.com/sdboyer/deptest"
8+
version = "0.8.1"

cmd/dep/testdata/harness_tests/ensure/package/case1/initial/main.go cmd/dep/testdata/harness_tests/ensure/add/all-new-double-spec/initial/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
package main
66

77
import (
8-
_ "github.com/sdboyer/deptest"
8+
"github.com/sdboyer/deptesttres"
99
)
1010

1111
func main() {
12+
type a deptesttres.Bar
1213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commands": [
3+
["init", "-no-examples"],
4+
["ensure", "-add", "github.com/sdboyer/deptest", "github.com/sdboyer/[email protected]"]
5+
],
6+
"vendor-final": [
7+
"github.com/sdboyer/deptest",
8+
"github.com/sdboyer/deptesttres"
9+
]
10+
}

cmd/dep/testdata/harness_tests/ensure/add/all-new-double/final/Gopkg.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
[[constraint]]
33
name = "github.com/sdboyer/deptest"
4-
version = "0.8.0"
4+
version = "1.0.0"

cmd/dep/testdata/harness_tests/ensure/package/case2/initial/main.go cmd/dep/testdata/harness_tests/ensure/add/all-new-double/initial/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
package main
66

77
import (
8-
_ "github.com/sdboyer/deptest"
8+
"github.com/sdboyer/deptest"
99
)
1010

1111
func main() {
12+
type a deptest.Bar
1213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commands": [
3+
["init", "-no-examples"],
4+
["ensure", "-add", "github.com/sdboyer/deptesttres", "github.com/sdboyer/deptesttres/subp"]
5+
],
6+
"vendor-final": [
7+
"github.com/sdboyer/deptest",
8+
"github.com/sdboyer/deptesttres"
9+
]
10+
}

cmd/dep/testdata/harness_tests/ensure/add/all-new-spec/final/Gopkg.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
[[constraint]]
3+
branch = "master"
4+
name = "github.com/sdboyer/deptesttres"
5+
6+
[[constraint]]
7+
name = "github.com/sdboyer/deptest"
8+
version = "0.8.1"

cmd/dep/testdata/harness_tests/ensure/override/case1/initial/main.go cmd/dep/testdata/harness_tests/ensure/add/all-new-spec/initial/main.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
package main
66

77
import (
8-
"fmt"
9-
10-
stuff "github.com/sdboyer/deptest"
8+
"github.com/sdboyer/deptesttres"
119
)
1210

1311
func main() {
14-
fmt.Println(stuff.Thing)
12+
type a deptesttres.Bar
1513
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commands": [
3+
["init", "-no-examples"],
4+
["ensure", "-add", "github.com/sdboyer/[email protected]"]
5+
],
6+
"vendor-final": [
7+
"github.com/sdboyer/deptest",
8+
"github.com/sdboyer/deptesttres"
9+
]
10+
}

cmd/dep/testdata/harness_tests/ensure/add/all-new/final/Gopkg.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
branch = "master"
4+
name = "github.com/sdboyer/deptesttres"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"github.com/sdboyer/deptesttres"
9+
)
10+
11+
func main() {
12+
type a deptesttres.Bar
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commands": [
3+
["init", "-no-examples"],
4+
["ensure", "-add", "github.com/sdboyer/deptest"]
5+
],
6+
"vendor-final": [
7+
"github.com/sdboyer/deptest",
8+
"github.com/sdboyer/deptesttres"
9+
]
10+
}

cmd/dep/testdata/harness_tests/ensure/update/case2/initial/Gopkg.lock cmd/dep/testdata/harness_tests/ensure/add/errs/desync/final/Gopkg.lock

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/ensure/update/case2/final/Gopkg.lock cmd/dep/testdata/harness_tests/ensure/add/errs/desync/initial/Gopkg.lock

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"github.com/sdboyer/deptest"
9+
"github.com/sdboyer/deptestdos"
10+
)
11+
12+
func main() {
13+
err := nil
14+
if err != nil {
15+
deptest.Map["yo yo!"]
16+
}
17+
deptestdos.diMeLo("whatev")
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commands": [
3+
["ensure", "-add", "foobar.com/baz"]
4+
],
5+
"error-expected": "Gopkg.toml and Gopkg.lock are out of sync. Run a plain dep ensure to resync them before attempting to -add"
6+
}

cmd/dep/testdata/harness_tests/ensure/add/errs/double-diff-spec/final/Gopkg.lock

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
branch = "master"
4+
name = "github.com/sdboyer/deptesttres"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"github.com/sdboyer/deptesttres"
9+
)
10+
11+
func main() {
12+
type a deptesttres.Bar
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"commands": [
3+
["init", "-no-examples"],
4+
["ensure", "-add", "github.com/sdboyer/[email protected]", "github.com/sdboyer/[email protected]"]
5+
],
6+
"vendor-final": [
7+
"github.com/sdboyer/deptesttres"
8+
],
9+
"error-expected": "can only specify rules once per project being added; rules were given at least twice for github.com/sdboyer/deptest"
10+
}

cmd/dep/testdata/harness_tests/ensure/add/errs/exists-manifest/final/Gopkg.lock

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[[constraint]]
2+
name = "github.com/sdboyer/deptesttres"
3+
branch = "master"
4+
5+
[[constraint]]
6+
name = "github.com/sdboyer/deptest"
7+
version = "1.0.0"

0 commit comments

Comments
 (0)