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

Commit db9e1d0

Browse files
committed
Add failing test for dep ensure -update github.com/foo/bar
1 parent 9420aab commit db9e1d0

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

cmd/dep/ensure_test.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,110 @@ func TestDeduceConstraint(t *testing.T) {
186186
}
187187
}
188188
}
189+
190+
func TestEnsureUpdate(t *testing.T) {
191+
test.NeedsExternalNetwork(t)
192+
test.NeedsGit(t)
193+
194+
h := test.NewHelper(t)
195+
defer h.Cleanup()
196+
197+
h.TempDir("src")
198+
h.Setenv("GOPATH", h.Path("."))
199+
200+
m := `package main
201+
202+
import (
203+
"fmt"
204+
"github.com/pkg/errors"
205+
stuff "github.com/carolynvs/go-dep-test"
206+
)
207+
208+
func main() {
209+
fmt.Println(stuff.Thing)
210+
TryToDoSomething()
211+
}
212+
213+
func TryToDoSomething() error {
214+
return errors.New("I tried, Billy. I tried...")
215+
}
216+
`
217+
218+
h.TempFile("src/thing/thing.go", m)
219+
220+
origManifest := `{
221+
"dependencies": {
222+
"github.com/carolynvs/go-dep-test": {
223+
"version": "~0.1.0"
224+
}
225+
}
226+
}`
227+
h.TempFile("src/thing/manifest.json", origManifest)
228+
229+
origLock := `{
230+
"memo": "9a5243dd3fa20feeaa20398e7283d6c566532e2af1aae279a010df34793761c5",
231+
"projects": [
232+
{
233+
"name": "github.com/carolynvs/go-dep-test",
234+
"version": "0.1.0",
235+
"revision": "b9c5511fa463628e6251554db29a4be161d02aed",
236+
"packages": [
237+
"."
238+
]
239+
},
240+
{
241+
"name": "github.com/pkg/errors",
242+
"branch": "v0.7.0",
243+
"revision": "01fa4104b9c248c8945d14d9f128454d5b28d595",
244+
"packages": [
245+
"."
246+
]
247+
}
248+
]
249+
}
250+
`
251+
h.TempFile("src/thing/lock.json", origLock)
252+
h.Cd(h.Path("src/thing"))
253+
254+
h.Run("ensure", "-update", "github.com/carolynvs/go-dep-test")
255+
256+
expectedManifest := `{
257+
"dependencies": {
258+
"github.com/carolynvs/go-dep-test": {
259+
"version": "^0.1.0"
260+
}
261+
}
262+
}
263+
`
264+
manifest := h.ReadManifest()
265+
if manifest != expectedManifest {
266+
t.Fatalf("expected '%s', got '%s'", expectedManifest, manifest)
267+
}
268+
269+
expectedLock := `{
270+
"memo": "9a5243dd3fa20feeaa20398e7283d6c566532e2af1aae279a010df34793761c5",
271+
"projects": [
272+
{
273+
"name": "github.com/carolynvs/go-dep-test",
274+
"version": "0.1.1",
275+
"revision": "40691983e4002d3a3f5879cc0f1fe99bedda148c",
276+
"packages": [
277+
"."
278+
]
279+
},
280+
{
281+
"name": "github.com/pkg/errors",
282+
"branch": "v0.7.0",
283+
"revision": "01fa4104b9c248c8945d14d9f128454d5b28d595",
284+
"packages": [
285+
"."
286+
]
287+
}
288+
]
289+
}
290+
`
291+
lock := h.ReadLock()
292+
if lock != expectedLock {
293+
t.Fatalf("expected %s, got %s", expectedLock, lock)
294+
}
295+
}

0 commit comments

Comments
 (0)