3 # download with version should print nothing
4 go mod download rsc.io/quote@v1.5.0
7 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
8 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
9 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
11 # download -json with version should print JSON
12 go mod download -json 'rsc.io/quote@<=v1.5.0'
13 stdout '^\t"Path": "rsc.io/quote"'
14 stdout '^\t"Version": "v1.5.0"'
15 stdout '^\t"Info": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.0.info"'
16 stdout '^\t"GoMod": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.0.mod"'
17 stdout '^\t"Zip": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.0.zip"'
18 stdout '^\t"Sum": "h1:6fJa6E\+wGadANKkUMlZ0DhXFpoKlslOQDCo259XtdIE="' # hash of testdata/mod version, not real version!
19 stdout '^\t"GoModSum": "h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe\+TKr0="'
22 # download queries above should not have added to go.mod.
26 # add to go.mod so we can test non-query downloads
27 go mod edit -require rsc.io/quote@v1.5.2
28 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
29 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
30 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
32 # module loading will page in the info and mod files
34 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
35 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
36 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
38 # download will fetch and unpack the zip file
40 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info
41 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod
42 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip
43 exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2
46 stdout '^\t"Path": "rsc.io/quote"'
47 stdout '^\t"Version": "v1.5.2"'
48 stdout '^\t"Info": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.2.info"'
49 stdout '^\t"GoMod": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.2.mod"'
50 stdout '^\t"Zip": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)cache(\\\\|/)download(\\\\|/)rsc.io(\\\\|/)quote(\\\\|/)@v(\\\\|/)v1.5.2.zip"'
51 stdout '^\t"Dir": ".*(\\\\|/)pkg(\\\\|/)mod(\\\\|/)rsc.io(\\\\|/)quote@v1.5.2"'
53 # download will follow replacements
54 go mod edit -require rsc.io/quote@v1.5.1 -replace rsc.io/quote@v1.5.1=rsc.io/quote@v1.5.3-pre1
56 ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.zip
57 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.3-pre1.zip
59 # download will not follow replacements for explicit module queries
60 go mod download -json rsc.io/quote@v1.5.1
61 exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.1.zip