Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  env GO111MODULE=on
     2  [short] skip
     3  
     4  # With good go.sum, verify succeeds by avoiding download.
     5  cp go.sum.good go.sum
     6  go mod verify
     7  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
     8  
     9  # With bad go.sum, verify succeeds by avoiding download.
    10  cp go.sum.bad go.sum
    11  go mod verify
    12  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
    13  
    14  # With bad go.sum, sync (which must download) fails.
    15  rm go.sum
    16  cp go.sum.bad go.sum
    17  ! go mod tidy
    18  stderr 'checksum mismatch'
    19  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
    20  
    21  # With good go.sum, sync works.
    22  rm go.sum
    23  cp go.sum.good go.sum
    24  go mod tidy
    25  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip
    26  exists $GOPATH/pkg/mod/rsc.io/quote@v1.1.0/quote.go
    27  
    28  # go.sum should have the new checksum for go.mod
    29  grep '^rsc.io/quote v1.1.0/go.mod ' go.sum
    30  
    31  # verify should work
    32  go mod verify
    33  
    34  # basic loading of module graph should detect incorrect go.mod files.
    35  go mod graph
    36  cp go.sum.bad2 go.sum
    37  ! go mod graph
    38  stderr 'go.mod: checksum mismatch'
    39  
    40  # go.sum should be created and updated automatically.
    41  rm go.sum
    42  go mod graph
    43  exists go.sum
    44  grep '^rsc.io/quote v1.1.0/go.mod ' go.sum
    45  ! grep '^rsc.io/quote v1.1.0 ' go.sum
    46  
    47  go mod tidy
    48  grep '^rsc.io/quote v1.1.0/go.mod ' go.sum
    49  grep '^rsc.io/quote v1.1.0 ' go.sum
    50  
    51  # verify should fail on a missing ziphash. tidy should restore it.
    52  rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
    53  ! go mod verify
    54  stderr '^rsc.io/quote v1.1.0: missing ziphash: open '$GOPATH'[/\\]pkg[/\\]mod[/\\]cache[/\\]download[/\\]rsc.io[/\\]quote[/\\]@v[/\\]v1.1.0.ziphash'
    55  go mod tidy
    56  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
    57  go mod verify
    58  
    59  # Packages below module root should not be mentioned in go.sum.
    60  rm go.sum
    61  go mod edit -droprequire rsc.io/quote
    62  go get -d rsc.io/quote/buggy
    63  grep '^rsc.io/quote v1.5.2/go.mod ' go.sum
    64  ! grep buggy go.sum
    65  
    66  # non-existent packages below module root should not be mentioned in go.sum
    67  go mod edit -droprequire rsc.io/quote
    68  ! go list rsc.io/quote/morebuggy
    69  grep '^rsc.io/quote v1.5.2/go.mod ' go.sum
    70  ! grep buggy go.sum
    71  
    72  -- go.mod --
    73  module x
    74  require rsc.io/quote v1.1.0
    75  
    76  -- x.go --
    77  package x
    78  import _ "rsc.io/quote"
    79  
    80  -- go.sum.good --
    81  rsc.io/quote v1.1.0 h1:a3YaZoizPtXyv6ZsJ74oo2L4/bwOSTKMY7MAyo4O/0c=
    82  
    83  -- go.sum.bad --
    84  rsc.io/quote v1.1.0 h1:a3YaZoizPtXyv6ZsJ74oo2L4/bwOSTKMY7MAyo4O/1c=
    85  
    86  -- go.sum.bad2 --
    87  rsc.io/quote v1.1.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl1=
    88  

View as plain text