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

Commit

Permalink
Merge pull request #489 from sdboyer/new-ensure
Browse files Browse the repository at this point in the history
Implement new spec for `dep ensure`
  • Loading branch information
sdboyer committed Aug 4, 2017
2 parents c1aba4d + b8f7027 commit 7a91b79
Show file tree
Hide file tree
Showing 146 changed files with 1,815 additions and 232 deletions.
595 changes: 496 additions & 99 deletions cmd/dep/ensure.go

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions cmd/dep/ensure_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
"testing"

"github.com/golang/dep/internal/gps"
)

func TestInvalidEnsureFlagCombinations(t *testing.T) {
ec := &ensureCommand{
update: true,
add: true,
}

if err := ec.validateFlags(); err == nil {
t.Error("-add and -update together should fail validation")
}

ec.vendorOnly, ec.add = true, false
if err := ec.validateFlags(); err == nil {
t.Error("-vendor-only with -update should fail validation")
}

ec.add, ec.update = true, false
if err := ec.validateFlags(); err == nil {
t.Error("-vendor-only with -add should fail validation")
}

ec.noVendor, ec.add = true, false
if err := ec.validateFlags(); err == nil {
t.Error("-vendor-only with -no-vendor should fail validation")
}
ec.noVendor = false

// Also verify that the plain ensure path takes no args. This is a shady
// test, as lots of other things COULD return errors, and we don't check
// anything other than the error being non-nil. For now, it works well
// because a panic will quickly result if the initial arg length validation
// checks are incorrectly handled.
if err := ec.runDefault(nil, []string{"foo"}, nil, nil, gps.SolveParameters{}); err == nil {
t.Errorf("no args to plain ensure with -vendor-only")
}
ec.vendorOnly = false
if err := ec.runDefault(nil, []string{"foo"}, nil, nil, gps.SolveParameters{}); err == nil {
t.Errorf("no args to plain ensure")
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptesttres"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "0.8.1"
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
package main

import (
_ "github.com/sdboyer/deptest"
"github.com/sdboyer/deptesttres"
)

func main() {
type a deptesttres.Bar
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commands": [
["init", "-no-examples"],
["ensure", "-add", "github.com/sdboyer/deptest", "github.com/sdboyer/deptest@v0.8.1"]
],
"vendor-final": [
"github.com/sdboyer/deptest",
"github.com/sdboyer/deptesttres"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "0.8.0"
version = "1.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
package main

import (
_ "github.com/sdboyer/deptest"
"github.com/sdboyer/deptest"
)

func main() {
type a deptest.Bar
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commands": [
["init", "-no-examples"],
["ensure", "-add", "github.com/sdboyer/deptesttres", "github.com/sdboyer/deptesttres/subp"]
],
"vendor-final": [
"github.com/sdboyer/deptest",
"github.com/sdboyer/deptesttres"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptesttres"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "0.8.1"
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
package main

import (
"fmt"

stuff "github.com/sdboyer/deptest"
"github.com/sdboyer/deptesttres"
)

func main() {
fmt.Println(stuff.Thing)
type a deptesttres.Bar
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commands": [
["init", "-no-examples"],
["ensure", "-add", "github.com/sdboyer/deptest@v0.8.1"]
],
"vendor-final": [
"github.com/sdboyer/deptest",
"github.com/sdboyer/deptesttres"
]
}
21 changes: 21 additions & 0 deletions cmd/dep/testdata/harness_tests/ensure/add/all-new/final/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptesttres"
13 changes: 13 additions & 0 deletions cmd/dep/testdata/harness_tests/ensure/add/all-new/initial/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
"github.com/sdboyer/deptesttres"
)

func main() {
type a deptesttres.Bar
}
10 changes: 10 additions & 0 deletions cmd/dep/testdata/harness_tests/ensure/add/all-new/testcase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commands": [
["init", "-no-examples"],
["ensure", "-add", "github.com/sdboyer/deptest"]
],
"vendor-final": [
"github.com/sdboyer/deptest",
"github.com/sdboyer/deptesttres"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
"github.com/sdboyer/deptest"
"github.com/sdboyer/deptestdos"
)

func main() {
err := nil
if err != nil {
deptest.Map["yo yo!"]
}
deptestdos.diMeLo("whatev")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"commands": [
["ensure", "-add", "foobar.com/baz"]
],
"error-expected": "Gopkg.toml and Gopkg.lock are out of sync. Run a plain dep ensure to resync them before attempting to -add"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptesttres"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
"github.com/sdboyer/deptesttres"
)

func main() {
type a deptesttres.Bar
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commands": [
["init", "-no-examples"],
["ensure", "-add", "github.com/sdboyer/deptest@0.8.1", "github.com/sdboyer/deptest@1.0.0"]
],
"vendor-final": [
"github.com/sdboyer/deptesttres"
],
"error-expected": "can only specify rules once per project being added; rules were given at least twice for github.com/sdboyer/deptest"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[constraint]]
name = "github.com/sdboyer/deptesttres"
branch = "master"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"
Loading

0 comments on commit 7a91b79

Please sign in to comment.