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

     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.
     8  env testproxy=$GOPROXY
     9  env GOPROXY=file:///$WORK/proxy
    10  env 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.
    14  go list -m example.com/noversion
    15  stdout '^example.com/noversion v0.0.0$'
    16  go list -m -u example.com/noversion
    17  stdout '^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.
    21  go list -m example.com/nolatest
    22  stdout '^example.com/nolatest v0.0.0$'
    23  go list -m -u example.com/nolatest
    24  stdout '^example.com/nolatest v0.0.0$'
    25  
    26  # If proxy returns an invalid response, we should see an error.
    27  env GOPROXY=$testproxy/invalid
    28  ! go list -m -u example.com/nolatest
    29  stderr '^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 --
    32  module m
    33  
    34  go 1.17
    35  
    36  require (
    37  	example.com/nolatest v0.0.0
    38  	example.com/noversion v0.0.0
    39  )
    40  -- go.sum --
    41  example.com/nolatest v0.0.0/go.mod h1:HnLrCt6SJga5tCtJ7IzG9dOOCniY3G5C0VT7jfMdS0M=
    42  example.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 --
    47  module example.com/nolatest
    48  
    49  go 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 --
    53  module example.com/noversion
    54  
    55  go 1.17
    56  

View as plain text