this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: test publishing a module with no major version suffix

Including what commands the user might try running and what they do.
Adding this scenario because I was surprised to see that the
"does not contain major version" error was only covered in unit tests,
and we had no coverage for what the user may do in this case.

As part of writing this test, I uncovered three surprising behaviors
which are now recorded as TODOs.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I11c07f1dd823b36c676d8597ae3d8cda9ae9f21c
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195782
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+64
+64
cmd/cue/cmd/testdata/script/modpublish_no_major_suffix.txtar
··· 1 + # Test that cue mod publish fails when the module path lacks a major version suffix. 2 + # The module path can be fixed up with `cue mod fix` and then published successfully. 3 + # Using or developing the module locally works otherwise, even `cue mod tidy`. 4 + 5 + memregistry MEMREGISTRY 6 + env CUE_REGISTRY=$MEMREGISTRY+insecure 7 + 8 + exec cue export 9 + cmp stdout export.stdout 10 + exec cue mod tidy --check 11 + 12 + cp cue.mod/module.cue cue.mod/module.cue.original 13 + 14 + ! exec cue mod publish v0.0.1 15 + # TODO(mvdan): this error message should not use an absolute path. 16 + # TODO(mvdan): we should suggest what command to run to the user based on the version to publish. 17 + stderr 'module path "main.example" in '${WORK@R}\${/}cue.mod\${/}'module.cue does not contain major version' 18 + 19 + # Note that module commands like `cue mod tidy` work even without a major version suffix 20 + # as one is not required to fully use the current module locally, even with dependencies. 21 + exec cue mod tidy --check 22 + 23 + # `cue mod fix` adds a major version suffix "v0" when missing. 24 + # The user can use `cue mod edit --module` if they want a different major version. 25 + exec cue mod fix 26 + cmp cue.mod/module.cue cue.mod/module.cue.fixed 27 + 28 + # TODO(mvdan): we cannot edit the module to add a missing major version suffix, which seems like a bug. 29 + cp cue.mod/module.cue.original cue.mod/module.cue 30 + ! exec cue mod edit --module main.example@v0 31 + stderr 'module.cue does not contain major version' 32 + 33 + # Continue the test with the fixed v0 form. 34 + cp cue.mod/module.cue.fixed cue.mod/module.cue 35 + 36 + # Trying to publish with the wrong major version will fail. 37 + ! exec cue mod publish v1.0.0 38 + stderr 'mismatched major version suffix' 39 + ! exec cue mod publish v2.0.0 40 + stderr 'mismatched major version suffix' 41 + 42 + # Publishing with the right major version works. 43 + exec cue mod publish v0.0.1 44 + 45 + -- export.stdout -- 46 + { 47 + "out": "hello world" 48 + } 49 + -- cue.mod/module.cue -- 50 + module: "main.example" 51 + language: version: "v0.9.0" 52 + source: kind: "self" 53 + -- cue.mod/module.cue.fixed -- 54 + module: "main.example@v0" 55 + language: { 56 + version: "v0.9.0" 57 + } 58 + source: { 59 + kind: "self" 60 + } 61 + -- main.cue -- 62 + package main 63 + 64 + out: "hello world"