mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-03 13:11:05 +00:00
A local Docker build passed ARTEX_VERSION=dev, so every such install showed the same meaningless version and could not name its source. update.sh now stamps ARTEX_VERSION and ARTEX_REVISION from git before a rebuild (and no longer aborts when the pull is declined), Docker builds forward the revision and publish OCI labels, release images stamp the commit, and /health reports version, commit, Go version and build time. The top bar renders dev (abc1234) when a local build has no describe tag but does carry a revision.
28 lines
858 B
Go
28 lines
858 B
Go
package server
|
|
|
|
import "testing"
|
|
|
|
func TestCurrentBuildInfoUsesInjectedIdentity(t *testing.T) {
|
|
bi := currentBuildInfo("main-test", "0123456789abcdef")
|
|
if bi.Version != "main-test" {
|
|
t.Fatalf("Version = %q, want main-test", bi.Version)
|
|
}
|
|
if bi.Commit != "0123456789abcdef" {
|
|
t.Fatalf("Commit = %q, want the injected revision", bi.Commit)
|
|
}
|
|
if bi.GoVersion == "" {
|
|
t.Fatal("GoVersion is empty; debug.ReadBuildInfo should report the toolchain")
|
|
}
|
|
}
|
|
|
|
func TestCurrentBuildInfoDevWithoutRevision(t *testing.T) {
|
|
bi := currentBuildInfo("dev", "")
|
|
if bi.Version != "dev" {
|
|
t.Fatalf("Version = %q, want dev", bi.Version)
|
|
}
|
|
// A test binary has no VCS stamp, so the empty commit stays empty rather
|
|
// than turning into a misleading value.
|
|
if bi.Commit != "" {
|
|
t.Fatalf("Commit = %q, want empty when the build has no revision", bi.Commit)
|
|
}
|
|
}
|