Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit a2fdd78

Browse files
authored
Removing Version() check in tests. (#130)
It is a reasonable expectation from our customers that `go test` should execute without failure on master from their machines. At the moment, there is a by design failure because the version matches the most recently published tag. Eventually, we should enforce this again, but not until we can do so only for our own release pipeline. To ensure folks don't get snared on this, we'll delete the offending test here.
1 parent ec5f490 commit a2fdd78

File tree

2 files changed

+14
-111
lines changed

2 files changed

+14
-111
lines changed

autorest/version.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ package autorest
22

33
import (
44
"fmt"
5+
"strings"
6+
"sync"
57
)
68

79
const (
8-
major = "7"
9-
minor = "3"
10-
patch = "0"
11-
tag = ""
12-
semVerFormat = "%s.%s.%s%s"
10+
major = 7
11+
minor = 3
12+
patch = 1
13+
tag = ""
1314
)
1415

16+
var versionLock sync.Once
1517
var version string
1618

1719
// Version returns the semantic version (see http://semver.org).
1820
func Version() string {
19-
if version == "" {
20-
version = fmt.Sprintf(semVerFormat, major, minor, patch, tag)
21-
}
21+
versionLock.Do(func() {
22+
version = fmt.Sprintf("v%d.%d.%d", major, minor, patch)
23+
24+
if trimmed := strings.TrimPrefix(tag, "-"); trimmed != "" {
25+
version = fmt.Sprintf("%s-%s", version, trimmed)
26+
}
27+
})
2228
return version
2329
}

autorest/version_test.go

-103
This file was deleted.

0 commit comments

Comments
 (0)