package buildinfo

import "testing"

func TestNormalizeUsesFallbacks(t *testing.T) {
	t.Parallel()

	info := Normalize("", "  ", "\t")
	if info.Version != "dev" {
		t.Fatalf("Version = %q, want dev", info.Version)
	}
	if info.Commit != "unknown" {
		t.Fatalf("Commit = %q, want unknown", info.Commit)
	}
	if info.BuiltAt != "unknown" {
		t.Fatalf("BuiltAt = %q, want unknown", info.BuiltAt)
	}
}

func TestNormalizeTrimsValues(t *testing.T) {
	t.Parallel()

	info := Normalize(" v1.2.3 ", " abc123 ", " 2026-03-22T12:00:00Z ")
	if info.Version != "v1.2.3" {
		t.Fatalf("Version = %q, want v1.2.3", info.Version)
	}
	if info.Commit != "abc123" {
		t.Fatalf("Commit = %q, want abc123", info.Commit)
	}
	if info.BuiltAt != "2026-03-22T12:00:00Z" {
		t.Fatalf("BuiltAt = %q, want 2026-03-22T12:00:00Z", info.BuiltAt)
	}
}
