32 lines
712 B
Go
32 lines
712 B
Go
|
|
package mining
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestVersion_GetVersion_Good(t *testing.T) {
|
||
|
|
result := GetVersion()
|
||
|
|
if result == "" {
|
||
|
|
t.Fatal("expected non-empty version string")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestVersion_GetVersion_Bad(t *testing.T) {
|
||
|
|
// Default version is "dev" when ldflags are not set
|
||
|
|
result := GetVersion()
|
||
|
|
if result != "dev" {
|
||
|
|
// Not a failure — just means ldflags were set
|
||
|
|
t.Logf("version is %q (ldflags may be set)", result)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestVersion_GetVersion_Ugly(t *testing.T) {
|
||
|
|
// All three version functions should return non-empty strings
|
||
|
|
if GetCommit() == "" {
|
||
|
|
t.Fatal("expected non-empty commit string")
|
||
|
|
}
|
||
|
|
if GetBuildDate() == "" {
|
||
|
|
t.Fatal("expected non-empty build date string")
|
||
|
|
}
|
||
|
|
}
|