Something went wrong. Try again.
A concatenating Youtube uploader
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051package pkg
import ( "os" "testing")
func TestPlaylist(t *testing.T) { got := playlist([]string{"/videos/a.mp4", "/videos/b.mp4"}) want := "file '/videos/a.mp4'\nfile '/videos/b.mp4'\n"
if got != want { t.Errorf("playlist() = %q, want %q", got, want) }}
func TestEscapePath(t *testing.T) { tests := []struct { in string want string }{ {"/videos/plain.mp4", "/videos/plain.mp4"}, {"/videos/it's here.mp4", `/videos/it\'s here.mp4`}, {`/videos/back\slash.mp4`, `/videos/back\\slash.mp4`}, }
for _, test := range tests { if got := escapePath(test.in); got != test.want { t.Errorf("escapePath(%q) = %q, want %q", test.in, got, test.want) } }}
func TestWritePlaylist(t *testing.T) { name, err := writePlaylist([]string{"/videos/a.mp4", "/videos/b.mp4"}) if err != nil { t.Fatalf("writePlaylist() error = %v", err) } t.Cleanup(func() { _ = os.Remove(name) })
got, err := os.ReadFile(name) if err != nil { t.Fatalf("could not read playlist: %v", err) }
want := "file '/videos/a.mp4'\nfile '/videos/b.mp4'\n" if string(got) != want { t.Errorf("playlist file = %q, want %q", got, want) }}