package main import "testing" func TestScanIntish(t *testing.T) { cases := []struct { in any want int }{ {int64(42), 42}, {float64(3.9), 3}, {[]byte("12.50"), 12}, {"7", 7}, {nil, 0}, } for _, tc := range cases { if got := scanIntish(tc.in); got != tc.want { t.Fatalf("scanIntish(%v)=%d want %d", tc.in, got, tc.want) } } } func TestSummarizeOrphans(t *testing.T) { s := summarizeOrphans([]OrphanFinding{ {Check: "a", Pass: true}, {Check: "b", Pass: false}, {Check: "platform_admins", Pass: true, Count: 2}, {Check: "skipped_dry_run", Pass: true}, }) if s.Passed != 3 || s.Failed != 1 || s.Total != 4 { t.Fatalf("summary %#v", s) } } func TestMysqlSelectList(t *testing.T) { got := mysqlSelectList("id", "COALESCE(name, id)", "'en'") want := "SELECT id, COALESCE(name, id), 'en'" if got != want { t.Fatalf("got %q", got) } }