...

Text file src/cmd/go/testdata/script/mod_sumdb_proxy.txt

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2env sumdb=$GOSUMDB
     3env proxy=$GOPROXY
     4env GOPROXY GONOPROXY GOSUMDB GONOSUMDB
     5
     6# basic fetch (through proxy) works
     7cp go.mod.orig go.mod
     8go get rsc.io/fortune@v1.0.0 # note: must use test proxy, does not exist in real world
     9rm $GOPATH/pkg/mod/cache/download/sumdb # rm sumdb cache but NOT package download cache
    10rm go.sum
    11
    12# can fetch by explicit URL
    13cp go.mod.orig go.mod
    14env GOSUMDB=$sumdb' '$proxy/sumdb-direct
    15go get rsc.io/fortune@v1.0.0
    16rm $GOPATH/pkg/mod/cache/download/sumdb
    17rm go.sum
    18
    19# direct access fails (because localhost.localdev does not exist)
    20# web.get is providing the error message - there's no actual network access.
    21cp go.mod.orig go.mod
    22env GOSUMDB=$sumdb
    23env GOPROXY=direct
    24! go get rsc.io/fortune@v1.0.0
    25stderr 'verifying module: rsc.io/fortune@v1.0.0: .*: no such host localhost.localdev'
    26rm $GOPATH/pkg/mod/cache/download/sumdb
    27rm go.sum
    28
    29# proxy 404 falls back to direct access (which fails)
    30cp go.mod.orig go.mod
    31env GOSUMDB=$sumdb
    32env GOPROXY=$proxy/sumdb-404
    33! go get rsc.io/fortune@v1.0.0
    34stderr 'verifying.*localhost.localdev'
    35rm $GOPATH/pkg/mod/cache/download/sumdb
    36rm go.sum
    37
    38# proxy non-200/404/410 stops direct access
    39cp go.mod.orig go.mod
    40env GOSUMDB=$sumdb
    41env GOPROXY=$proxy/sumdb-503
    42! go get rsc.io/fortune@v1.0.0
    43stderr '503 Service Unavailable'
    44rm $GOPATH/pkg/mod/cache/download/sumdb
    45rm go.sum
    46
    47# the error from the last attempted proxy should be returned.
    48cp go.mod.orig go.mod
    49env GOSUMDB=$sumdb
    50env GOPROXY=$proxy/sumdb-404,$proxy/sumdb-503
    51! go get rsc.io/fortune@v1.0.0
    52stderr '503 Service Unavailable'
    53rm $GOPATH/pkg/mod/cache/download/sumdb
    54rm go.sum
    55
    56# if proxies are separated with '|', fallback is allowed on any error.
    57cp go.mod.orig go.mod
    58env GOSUMDB=$sumdb
    59env GOPROXY=$proxy/sumdb-503|https://0.0.0.0|$proxy
    60go get rsc.io/fortune@v1.0.0
    61rm $GOPATH/pkg/mod/cache/download/sumdb
    62rm go.sum
    63
    64-- go.mod.orig --
    65module m

View as plain text