-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion_test.go
More file actions
45 lines (40 loc) · 1.23 KB
/
Copy pathversion_test.go
File metadata and controls
45 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package godo
import "testing"
func TestTaggedVersion(t *testing.T) {
cases := []struct {
in string
want bool
}{
{"v0.3.0", true},
{"v0.3.0-preview.1", true},
{"", false},
{"(devel)", false},
// What `go build` in a working tree records.
{"v0.2.1-0.20260921040944-a467864ac83c+dirty", false},
// The same without the dirty marker: still nothing anyone tagged.
{"v0.2.1-0.20260921040944-a467864ac83c", false},
{"v2.0.0+incompatible", false},
}
for _, c := range cases {
if got := taggedVersion(c.in); got != c.want {
t.Errorf("taggedVersion(%q) = %v, want %v", c.in, got, c.want)
}
}
}
// A stamped build wins over anything the build info says: the release is the
// authority on what it released.
func TestReleasePrefersStampedVersion(t *testing.T) {
old := Version
defer func() { Version = old }()
Version = "v0.3.0"
if got := Release(); got != "v0.3.0" {
t.Fatalf("Release() = %q, want the stamped version", got)
}
}
// Unstamped, in a test binary, there is no tag to find, so the default stands
// rather than a pseudo-version pretending to be a release.
func TestReleaseFallsBackToDefault(t *testing.T) {
if got := Release(); got != devVersion {
t.Fatalf("Release() = %q, want %q", got, devVersion)
}
}