gralculator/internal/version/version_test.go

25 lines
435 B
Go
Raw Permalink Normal View History

package version
import (
"strings"
"testing"
)
func TestString(t *testing.T) {
// default dev
if got := String(); got != "dev" {
t.Errorf("default: want dev, got %s", got)
}
// with commit
Version = "1.0.0"
Commit = "abc123"
if got := String(); !strings.Contains(got, "1.0.0") || !strings.Contains(got, "abc123") {
t.Errorf("with commit: want version-commit, got %s", got)
}
// reset
Version = "dev"
Commit = ""
}