1 # Download modules and populate go.sum.
2 go get -modcacherw
3 exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
4
5 # 'go mod verify' should fail if we delete a file.
6 go mod verify
7 rm $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
8 ! go mod verify
9
10 # Create a .partial file to simulate an failure extracting the zip file.
11 cp empty $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.partial
12
13 # 'go mod verify' should not fail, since the module hasn't been completely
14 # ingested into the cache.
15 go mod verify
16
17 # 'go list' should not load packages from the directory.
18 # NOTE: the message "directory $dir outside main module or its selected dependencies"
19 # is reported for directories not in the main module, active modules in the
20 # module cache, or local replacements. In this case, the directory is in the
21 # right place, but it's incomplete, so 'go list' acts as if it's not an
22 # active module.
23 ! go list $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
24 stderr 'outside main module or its selected dependencies'
25
26 # 'go list -m' should not print the directory.
27 go list -m -f '{{.Dir}}' rsc.io/quote
28 ! stdout .
29
30 # 'go mod download' should re-extract the module and remove the .partial file.
31 go mod download -modcacherw rsc.io/quote
32 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.partial
33 exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
34
35 # 'go list' should succeed.
36 go list $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
37 stdout '^rsc.io/quote$'
38
39 # 'go list -m' should print the directory.
40 go list -m -f '{{.Dir}}' rsc.io/quote
41 stdout 'pkg[/\\]mod[/\\]rsc.io[/\\]quote@v1.5.2'
42
43 # go mod verify should fail if we delete a file.
44 go mod verify
45 rm $GOPATH/pkg/mod/rsc.io/quote@v1.5.2/go.mod
46 ! go mod verify
47
48 # 'go mod download' should not leave behind a directory or a .partial file
49 # if there is an error extracting the zip file.
50 rm $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
51 cp empty $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
52 ! go mod download
53 stderr 'not a valid zip file'
54 ! exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
55 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.partial
56
57 -- go.mod --
58 module m
59
60 go 1.14
61
62 require rsc.io/quote v1.5.2
63
64 -- use.go --
65 package use
66
67 import _ "rsc.io/quote"
68
69 -- empty --
70
View as plain text