...

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

Documentation: cmd/go/testdata/script

     1# Check that if a proxy does not have a version of a module that could be
     2# an upgrade, 'go list -m -u' still succeeds.
     3# We use a local file proxy, since our test proxy doesn't have the behavior
     4# we want to test, and we don't want it to be too clever.
     5# Verifies #45305, where proxy.golang.org serves an empty /@v/list (200)
     6# but has no /@latest (410) because the go.mod at the tip of the default
     7# branch has a different major version suffix.
     8env testproxy=$GOPROXY
     9env GOPROXY=file:///$WORK/proxy
    10env GOSUMDB=off
    11
    12# If the proxy does not return a list of versions (404/410)
    13# or a latest version (404/410), we should see no error.
    14go list -m example.com/noversion
    15stdout '^example.com/noversion v0.0.0$'
    16go list -m -u example.com/noversion
    17stdout '^example.com/noversion v0.0.0$'
    18
    19# If the proxy returns an empty list of versions (200, not 404/410)
    20# but does not have a latest version (404/410), we should see no error.
    21go list -m example.com/nolatest
    22stdout '^example.com/nolatest v0.0.0$'
    23go list -m -u example.com/nolatest
    24stdout '^example.com/nolatest v0.0.0$'
    25
    26# If proxy returns an invalid response, we should see an error.
    27env GOPROXY=$testproxy/invalid
    28! go list -m -u example.com/nolatest
    29stderr '^go: loading module retractions for example.com/nolatest@v0.0.0: invalid response from proxy "[^"]*": invalid character ''i'' looking for beginning of value$'
    30
    31-- go.mod --
    32module m
    33
    34go 1.17
    35
    36require (
    37	example.com/nolatest v0.0.0
    38	example.com/noversion v0.0.0
    39)
    40-- go.sum --
    41example.com/nolatest v0.0.0/go.mod h1:HnLrCt6SJga5tCtJ7IzG9dOOCniY3G5C0VT7jfMdS0M=
    42example.com/noversion v0.0.0/go.mod h1:2RUfWiCYsygSXPM2Igxx0FD3Kq33OnVdxm34eDDhXbQ=
    43-- $WORK/proxy/example.com/nolatest/@v/list --
    44-- $WORK/proxy/example.com/nolatest/@v/v0.0.0.info --
    45{"Version":"v0.0.0"}
    46-- $WORK/proxy/example.com/nolatest/@v/v0.0.0.mod --
    47module example.com/nolatest
    48
    49go 1.17
    50-- $WORK/proxy/example.com/noversion/@v/v0.0.0.info --
    51{"Version":"v0.0.0"}
    52-- $WORK/proxy/example.com/noversion/@v/v0.0.0.mod --
    53module example.com/noversion
    54
    55go 1.17

View as plain text