(Fix): Fixed version mismatched causing one test to fail

This commit is contained in:
2025-11-22 10:16:57 +00:00
parent bb47c427f9
commit 8081085f87

View File

@@ -8,19 +8,15 @@ import (
func TestVersion(t *testing.T) { func TestVersion(t *testing.T) {
v := Version() v := Version()
// Check that version is not empty
if v == "" { if v == "" {
t.Error("Version() returned empty string") t.Error("Version() returned empty string")
} }
// Check format (should be X.Y.Z)
parts := strings.Split(v, ".") parts := strings.Split(v, ".")
if len(parts) != 3 { if len(parts) != 3 {
t.Errorf("Version() = %q; expected format X.Y.Z", v) t.Errorf("Version() = %q; expected format X.Y.Z", v)
} }
expected := "1.0.3"
// Verify it matches the constants
expected := "1.0.0"
if v != expected { if v != expected {
t.Errorf("Version() = %q; want %q", v, expected) t.Errorf("Version() = %q; want %q", v, expected)
} }
@@ -29,56 +25,47 @@ func TestVersion(t *testing.T) {
func TestFullVersion(t *testing.T) { func TestFullVersion(t *testing.T) {
fv := FullVersion() fv := FullVersion()
// Check that full version is not empty
if fv == "" { if fv == "" {
t.Error("FullVersion() returned empty string") t.Error("FullVersion() returned empty string")
} }
// Check that it contains "Zipprine"
if !strings.Contains(fv, "Zipprine") { if !strings.Contains(fv, "Zipprine") {
t.Errorf("FullVersion() = %q; expected to contain 'Zipprine'", fv) t.Errorf("FullVersion() = %q; expected to contain 'Zipprine'", fv)
} }
// Check that it contains the version
if !strings.Contains(fv, Version()) { if !strings.Contains(fv, Version()) {
t.Errorf("FullVersion() = %q; expected to contain version %q", fv, Version()) t.Errorf("FullVersion() = %q; expected to contain version %q", fv, Version())
} }
// Verify exact format expected := "Zipprine v1.0.3"
expected := "Zipprine v1.0.0"
if fv != expected { if fv != expected {
t.Errorf("FullVersion() = %q; want %q", fv, expected) t.Errorf("FullVersion() = %q; want %q", fv, expected)
} }
} }
func TestVersionConstants(t *testing.T) { func TestVersionConstants(t *testing.T) {
// Test that constants are set correctly
if Major != 1 { if Major != 1 {
t.Errorf("Major = %d; want 1", Major) t.Errorf("Major = %d; want 1", Major)
} }
if Minor != 0 { if Minor != 0 {
t.Errorf("Minor = %d; want 0", Minor) t.Errorf("Minor = %d; want 0", Minor)
} }
if Patch != 0 { if Patch != 3 {
t.Errorf("Patch = %d; want 0", Patch) t.Errorf("Patch = %d; want 3", Patch)
} }
} }
func TestVersionFormat(t *testing.T) { func TestVersionFormat(t *testing.T) {
// Test that version follows semantic versioning
v := Version() v := Version()
// Should not contain spaces
if strings.Contains(v, " ") { if strings.Contains(v, " ") {
t.Errorf("Version() contains spaces: %q", v) t.Errorf("Version() contains spaces: %q", v)
} }
// Should not contain 'v' prefix
if strings.HasPrefix(v, "v") { if strings.HasPrefix(v, "v") {
t.Errorf("Version() should not have 'v' prefix: %q", v) t.Errorf("Version() should not have 'v' prefix: %q", v)
} }
// Should be numeric with dots
for i, c := range v { for i, c := range v {
if c != '.' && (c < '0' || c > '9') { if c != '.' && (c < '0' || c > '9') {
t.Errorf("Version() contains non-numeric character at position %d: %q", i, v) t.Errorf("Version() contains non-numeric character at position %d: %q", i, v)
@@ -89,13 +76,11 @@ func TestVersionFormat(t *testing.T) {
func TestFullVersionFormat(t *testing.T) { func TestFullVersionFormat(t *testing.T) {
fv := FullVersion() fv := FullVersion()
// Should start with "Zipprine v"
expectedPrefix := "Zipprine v" expectedPrefix := "Zipprine v"
if !strings.HasPrefix(fv, expectedPrefix) { if !strings.HasPrefix(fv, expectedPrefix) {
t.Errorf("FullVersion() should start with %q, got %q", expectedPrefix, fv) t.Errorf("FullVersion() should start with %q, got %q", expectedPrefix, fv)
} }
// Should end with version number
if !strings.HasSuffix(fv, Version()) { if !strings.HasSuffix(fv, Version()) {
t.Errorf("FullVersion() should end with version %q, got %q", Version(), fv) t.Errorf("FullVersion() should end with version %q, got %q", Version(), fv)
} }