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

Commit 686e331

Browse files
committed
Add a handful more harness tests
Also some comment cleanup, and relocate an errant test.
1 parent 9825b72 commit 686e331

File tree

22 files changed

+243
-43
lines changed

22 files changed

+243
-43
lines changed

cmd/dep/ensure.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
480480

481481
instr.ephReq[path] = true
482482
instr.typ |= isInManifest
483-
//p.Manifest.Required = append(p.Manifest.Required, path)
484483
} else if inImports {
485484
if !someConstraint {
486485
if exmap[path] {
@@ -539,8 +538,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
539538
}
540539
solution, err := solver.Solve()
541540
if err != nil {
542-
// TODO(sdboyer) detect if the failure was specifically about some of
543-
// the -add arguments
541+
// TODO(sdboyer) detect if the failure was specifically about some of the -add arguments
544542
handleAllTheFailuresOfTheWorld(err)
545543
return errors.Wrap(err, "ensure Solve()")
546544
}

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

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
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"
Lines changed: 13 additions & 0 deletions
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+
}
Lines changed: 10 additions & 0 deletions
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

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
name = "github.com/sdboyer/deptest"
4+
version = "1.0.0"
Lines changed: 13 additions & 0 deletions
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/deptest"
9+
)
10+
11+
func main() {
12+
type a deptest.Bar
13+
}
Lines changed: 10 additions & 0 deletions
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

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
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"
Lines changed: 13 additions & 0 deletions
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+
}
Lines changed: 10 additions & 0 deletions
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

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
branch = "master"
4+
name = "github.com/sdboyer/deptesttres"
Lines changed: 13 additions & 0 deletions
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+
}
Lines changed: 10 additions & 0 deletions
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/add/errs/double-diff-spec/final/Gopkg.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
branch = "master"
4+
name = "github.com/sdboyer/deptesttres"
Lines changed: 13 additions & 0 deletions
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+
}
Lines changed: 10 additions & 0 deletions
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+
}

internal/gps/source_manager_test.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -81,43 +81,3 @@ func TestSourceManager_InferConstraint_InvalidInput(t *testing.T) {
8181
}
8282
}
8383
}
84-
85-
func TestInvalidEnsureFlagCombinations(t *testing.T) {
86-
ec := &ensureCommand{
87-
update: true,
88-
add: true,
89-
}
90-
91-
if err := ec.validateFlags(); err == nil {
92-
t.Error("-add and -update together should fail validation")
93-
}
94-
95-
ec.vendorOnly, ec.add = true, false
96-
if err := ec.validateFlags(); err == nil {
97-
t.Error("-vendor-only with -update should fail validation")
98-
}
99-
100-
ec.add, ec.update = true, false
101-
if err := ec.validateFlags(); err == nil {
102-
t.Error("-vendor-only with -add should fail validation")
103-
}
104-
105-
ec.noVendor, ec.add = true, false
106-
if err := ec.validateFlags(); err == nil {
107-
t.Error("-vendor-only with -no-vendor should fail validation")
108-
}
109-
ec.noVendor = false
110-
111-
// Also verify that the plain ensure path takes no args. This is a shady
112-
// test, as lots of other things COULD return errors, and we don't check
113-
// anything other than the error being non-nil. For now, it works well
114-
// because a panic will quickly result if the initial arg length validation
115-
// checks are incorrectly handled.
116-
if err := ec.runDefault(nil, []string{"foo"}, nil, nil, gps.SolveParameters{}); err == nil {
117-
t.Errorf("no args to plain ensure with -vendor-only")
118-
}
119-
ec.vendorOnly = false
120-
if err := ec.runDefault(nil, []string{"foo"}, nil, nil, gps.SolveParameters{}); err == nil {
121-
t.Errorf("no args to plain ensure")
122-
}
123-
}

0 commit comments

Comments
 (0)