mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
re-init because of weird subtree shit
This commit is contained in:
commit
68254ddd13
85 changed files with 13501 additions and 0 deletions
14
src/common/version/BUILD.bazel
Normal file
14
src/common/version/BUILD.bazel
Normal file
|
@ -0,0 +1,14 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "version",
|
||||
srcs = ["version.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/common/version",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "version_test",
|
||||
srcs = ["version_test.go"],
|
||||
embed = [":version"],
|
||||
)
|
21
src/common/version/version.go
Normal file
21
src/common/version/version.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
GitCommit = "unknown"
|
||||
GitBranch = "unknown"
|
||||
BuildDate = "unknown"
|
||||
)
|
||||
|
||||
func StartupInfo(serviceName string) string {
|
||||
return fmt.Sprintf(
|
||||
"Starting %s service.\n Build %s (%s) at %s",
|
||||
serviceName,
|
||||
GitCommit,
|
||||
GitBranch,
|
||||
BuildDate,
|
||||
)
|
||||
}
|
18
src/common/version/version_test.go
Normal file
18
src/common/version/version_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStartup(t *testing.T) {
|
||||
GitBranch = "test"
|
||||
GitCommit = "e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"
|
||||
BuildDate = time.Now().UTC().Format("2006-01-02T15:04:05.000Z")
|
||||
|
||||
expected := "Starting test service.\n Build e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e (test) at " + BuildDate
|
||||
value := StartupInfo("test")
|
||||
if value != expected {
|
||||
t.Error("Incorrect render, got `", value, "`")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue