-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: move version to shared folder * chg: fmt for FullVersion func * chg: DetailedVersionInfo * chg: format on save * chg: test for ConvertToNumeric * chg: new compile options * wip: 1.8.4 * chg: travis is broken * mv: version into shared
- Loading branch information
Showing
12 changed files
with
239 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"runtime" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// // GitCommit - The git commit that was compiled. This will be filled in by the compiler. | ||
// var GitCommit string | ||
|
||
// // Version - The main version number that is being run at the moment. | ||
// const Version = "0.1.0" | ||
|
||
// VersionPrerelease - A pre-release marker for the version. If this is "" (empty string) | ||
// then it means that it is a final release. Otherwise, this is a pre-release | ||
// such as "dev" (in development) | ||
var VersionPrerelease = "" | ||
|
||
// Version of this chatbot binary | ||
var Version = "<Unknown>" | ||
|
||
// BuildDate is the build date of this chatbot binary | ||
var BuildDate = "<Unknown>" | ||
|
||
// GitCommit is the git SHA of this chatbot binary | ||
var GitCommit = "<Unknown>" | ||
|
||
// GoVersion is the version of Golang used to build flight-director | ||
var GoVersion = runtime.Version() | ||
|
||
// FullVersion - | ||
func FullVersion() string { | ||
return Version + VersionPrerelease + " (" + GitCommit + ")" | ||
} | ||
|
||
// DetailedVersionInfo returns a string with a bunch of info about go-chatbot-lab, | ||
// meant for putting in a `Server` response header, a `User-Agent` | ||
// request header, etc. | ||
func DetailedVersionInfo() string { | ||
return fmt.Sprintf( | ||
"Go-Chatbot-Lab %s; buildDate=%s; sha=%s", | ||
Version, BuildDate, GitCommit, | ||
) | ||
} | ||
|
||
// ConvertToNumeric converts a version string (. separated) into a numeric value for easier > and < comparisons | ||
func ConvertToNumeric(version string) float64 { | ||
parts := strings.Split(version, ".") | ||
var number float64 | ||
for i, s := range parts { | ||
part, _ := strconv.Atoi(s) | ||
number += math.Pow(1000, float64(len(parts)-(i+1))) * float64(part) | ||
} | ||
|
||
return number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package version_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestVersion(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Version Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package version_test | ||
|
||
import ( | ||
. "github.com/bossjones/go-chatbot-lab/shared/version" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Version", func() { | ||
|
||
Describe("Default Version variables", func() { | ||
It("should be <Unknown>", func() { | ||
Expect(VersionPrerelease).To(Equal("")) | ||
Expect(Version).To(Equal("<Unknown>")) | ||
Expect(BuildDate).To(Equal("<Unknown>")) | ||
Expect(GitCommit).To(Equal("<Unknown>")) | ||
// Expect(GoVersion).To(BeNumerically(">", "go1.9.2")) | ||
}) | ||
}) | ||
|
||
Describe("Func FullVersion", func() { | ||
It("returns a properly formatted string", func() { | ||
full_version := FullVersion() | ||
expected_full_version := "<Unknown> (<Unknown>)" | ||
|
||
Expect(full_version).To(Equal(expected_full_version)) | ||
}) | ||
}) | ||
|
||
Describe("Func DetailedVersionInfo", func() { | ||
It("returns a properly formatted string", func() { | ||
detailed_version_info := DetailedVersionInfo() | ||
expected_detailed_version_info := "Go-Chatbot-Lab <Unknown>; buildDate=<Unknown>; sha=<Unknown>" | ||
|
||
Expect(detailed_version_info).To(Equal(expected_detailed_version_info)) | ||
}) | ||
}) | ||
|
||
Describe("Func ConvertToNumeric", func() { | ||
It("returns a properly formatted string", func() { | ||
detailed_convert_to_numeric := ConvertToNumeric("1.2.1") | ||
expected_detailed_convert_to_numeric := 1.002001e+06 | ||
|
||
Expect(detailed_convert_to_numeric).To(Equal(expected_detailed_convert_to_numeric)) | ||
}) | ||
}) | ||
|
||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.