Export - GET /l/<list>/export?format=csv|txt downloads a list's titles in rank order, one per line, with no header or other fields (CSV gets a UTF-8 BOM for Excel) - Export menu in the list editor and, for the owner, on the public list page; hidden lists stay owner-only Custom lists - New "Custom" category for anything not built in (sports teams, drinks…): owner-named, slug from the title, entries added by hand or from an unfiltered Wikipedia search - Per-list artwork shape (square or tall), stored in a new lists.art column (migration 2) - Art can be uploaded while adding an entry, not only after Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
829 B
Go
29 lines
829 B
Go
package server
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestWriteTitles(t *testing.T) {
|
|
titles := []string{"Hamilton", `Les Misérables`, `Sweeney Todd: The "Demon" Barber, of Fleet Street`, "Two\nLines"}
|
|
|
|
var txt strings.Builder
|
|
if err := writeTitles(&txt, "txt", titles); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
wantTxt := "Hamilton\nLes Misérables\nSweeney Todd: The \"Demon\" Barber, of Fleet Street\nTwo Lines\n"
|
|
if txt.String() != wantTxt {
|
|
t.Errorf("txt:\n%q\nwant\n%q", txt.String(), wantTxt)
|
|
}
|
|
|
|
var csv strings.Builder
|
|
if err := writeTitles(&csv, "csv", titles); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
wantCSV := "\xef\xbb\xbfHamilton\r\nLes Misérables\r\n\"Sweeney Todd: The \"\"Demon\"\" Barber, of Fleet Street\"\r\nTwo Lines\r\n"
|
|
if csv.String() != wantCSV {
|
|
t.Errorf("csv:\n%q\nwant\n%q", csv.String(), wantCSV)
|
|
}
|
|
}
|