package cli import "testing" func TestSanitizeSlug(t *testing.T) { tests := map[string]string{ "Hello Astro": "hello-astro", " Go / Astro_Blog! ": "go-astro-blog", "Already--Clean": "already-clean", "喜欢你": "", "abc123": "abc123", } for input, want := range tests { if got := sanitizeSlug(input); got != want { t.Fatalf("sanitizeSlug(%q) = %q, want %q", input, got, want) } } } func TestFallbackSlug(t *testing.T) { if got := fallbackSlug("Hello Astro"); got != "hello-astro" { t.Fatalf("fallbackSlug english = %q", got) } got := fallbackSlug("喜欢你") if len(got) <= len("post-") || got[:5] != "post-" { t.Fatalf("fallbackSlug non-ascii = %q, want post-*", got) } } func TestFormatYAMLStringList(t *testing.T) { got := formatYAMLStringList([]string{"go", `astro "site"`}) want := `["go", "astro \"site\""]` if got != want { t.Fatalf("formatYAMLStringList = %q, want %q", got, want) } }