MCPcopy Create free account
hub / github.com/github/gh-aw / TestIsPreciseVersion

Function TestIsPreciseVersion

pkg/cli/semver_precise_test.go:9–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIsPreciseVersion(t *testing.T) {
10 tests := []struct {
11 name string
12 version string
13 expected bool
14 }{
15 {
16 name: "major only - not precise",
17 version: "v6",
18 expected: false,
19 },
20 {
21 name: "major.minor - not precise",
22 version: "v6.0",
23 expected: false,
24 },
25 {
26 name: "major.minor.patch - precise",
27 version: "v6.0.0",
28 expected: true,
29 },
30 {
31 name: "major.minor.patch non-zero - precise",
32 version: "v6.0.1",
33 expected: true,
34 },
35 {
36 name: "full version - precise",
37 version: "v6.1.2",
38 expected: true,
39 },
40 {
41 name: "without v prefix - precise",
42 version: "6.0.0",
43 expected: true,
44 },
45 {
46 name: "single digit major - not precise",
47 version: "v1",
48 expected: false,
49 },
50 {
51 name: "three component version - precise",
52 version: "v1.2.3",
53 expected: true,
54 },
55 }
56
57 for _, tt := range tests {
58 t.Run(tt.name, func(t *testing.T) {
59 v := parseVersion(tt.version)
60 if v == nil {
61 t.Fatalf("Failed to parse version: %s", tt.version)
62 }
63
64 result := v.IsPreciseVersion()
65 if result != tt.expected {
66 t.Errorf("isPreciseVersion() for %q = %v, want %v", tt.version, result, tt.expected)

Callers

nothing calls this directly

Calls 4

IsPreciseVersionMethod · 0.80
parseVersionFunction · 0.70
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected