...
1env GO111MODULE=on
2
3# For this test module there are three versions:
4# * v0.1.1-0.20190429073117-b5426c86b553
5# * v0.1.0
6# * v0.0.0-20190430073000-30950c05d534
7# Only v0.1.0 is tagged.
8#
9# The v0.1.1 pseudo-version is semantically higher than the latest tag.
10# The v0.0.0 pseudo-version is chronologically newer.
11
12# Start at v0.1.1-0.20190429073117-b5426c86b553
13go get example.com/pseudoupgrade@b5426c8
14go list -m -u all
15stdout '^example.com/pseudoupgrade v0.1.1-0.20190429073117-b5426c86b553$'
16
17# 'get -u' should not downgrade to the (lower) tagged version.
18go get -u
19go list -m -u all
20stdout '^example.com/pseudoupgrade v0.1.1-0.20190429073117-b5426c86b553$'
21
22# 'get example.com/pseudoupgrade@upgrade' should not downgrade.
23go get example.com/pseudoupgrade@upgrade
24go list -m all
25stdout '^example.com/pseudoupgrade v0.1.1-0.20190429073117-b5426c86b553$'
26
27# 'get example.com/pseudoupgrade' should not downgrade.
28# This is equivalent to 'get example.com/pseudoupgrade@upgrade'.
29go get example.com/pseudoupgrade
30go list -m all
31stdout '^example.com/pseudoupgrade v0.1.1-0.20190429073117-b5426c86b553$'
32
33# 'get example.com/pseudoupgrade@latest' should downgrade.
34# @latest should not consider the current version.
35go get example.com/pseudoupgrade@latest
36go list -m all
37stdout '^example.com/pseudoupgrade v0.1.0$'
38
39# We should observe the same behavior with the newer pseudo-version.
40go get example.com/pseudoupgrade@v0.0.0-20190430073000-30950c05d534
41
42# 'get -u' should not downgrade to the chronologically older tagged version.
43go get -u
44go list -m -u all
45stdout '^example.com/pseudoupgrade v0.0.0-20190430073000-30950c05d534$'
46
47# 'get example.com/pseudoupgrade@upgrade should not downgrade.
48go get example.com/pseudoupgrade@upgrade
49go list -m -u all
50stdout '^example.com/pseudoupgrade v0.0.0-20190430073000-30950c05d534$'
51
52# 'get example.com/pseudoupgrade' should not downgrade.
53go get example.com/pseudoupgrade
54go list -m -u all
55stdout '^example.com/pseudoupgrade v0.0.0-20190430073000-30950c05d534$'
56
57# 'get example.com/pseudoupgrade@latest' should downgrade.
58go get example.com/pseudoupgrade@latest
59go list -m -u all
60stdout '^example.com/pseudoupgrade v0.1.0$'
61
62-- go.mod --
63module x
64
65go 1.12
66
67-- main.go --
68package x
69
70import _ "example.com/pseudoupgrade"
View as plain text