Files
bbs/internal/server/chanconfig_test.go
T
Claude 114e56c928 Image boards: an archive of pruned threads
As 4chan's, a thread pruned off a board's last page is archived, not
deleted: off the board's pages and catalog, whole, its files kept,
read-only.  No one replies to it, staff neither (store.AddPost refuses
too, for a reply already on its way); its posts are not deleted by
their passwords (staff still can).  Its page says it is archived in
place of the form and its first post wears a badge.

- /chan/b/archive lists a board's archived threads, the last first;
  /chan/b/archive.json is 4chan's (the numbers, oldest first); an
  archived thread's JSON has archived and archived_on, and boards.json
  is_archived
- [chan] archive_days (3; 0: always) is how long they stay: then they
  are deleted with their files, looked to when a thread is made and
  when the archive or the thread is looked at
- a board's archive setting (bbs chan board set DIR archive no) prunes
  as before, deleting at once; boards have one by default, as do
  those of an older database
- the terminals: a board's thread list has Archive (A), to read them;
  archived threads offer no reply

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
2026-10-14 18:17:57 +00:00

45 lines
1.6 KiB
Go

package server
import (
"os"
"path/filepath"
"strings"
"testing"
"time"
)
// [chan]'s helpers for videos' and PDFs' thumbnails, found on the PATH,
// and a video's longest length.
func TestChanMediaConfig(t *testing.T) {
load := func(body string) (*Config, error) {
p := filepath.Join(t.TempDir(), "bbs.conf")
os.WriteFile(p, []byte("[listen telnet]\ntype = telnet\naddress = :2300\n"+body), 0600)
return Load(p)
}
c, err := load("[chan]\n")
if err != nil || c.Chan.FFmpeg != "" || c.Chan.MaxVideo != 120*time.Second {
t.Fatalf("defaults: %+v %v", c.Chan, err)
}
if c.Chan.ArchiveFor != 72*time.Hour {
t.Errorf("archive_days by default: %v", c.Chan.ArchiveFor)
}
if c, err := load("[chan]\narchive_days = 0\n"); err != nil || c.Chan.ArchiveFor != 0 {
t.Errorf("archive_days 0: %v %v", c.Chan.ArchiveFor, err)
}
c, err = load("[chan]\nffmpeg = sh\nmax_video = 300\n")
if err != nil || !filepath.IsAbs(c.Chan.FFmpeg) || c.Chan.MaxVideo != 300*time.Second {
t.Fatalf("set: %q %v %v", c.Chan.FFmpeg, c.Chan.MaxVideo, err)
}
if _, err := load("[chan]\npdftoppm = no-such-helper-here\n"); err == nil || !strings.Contains(err.Error(), "pdftoppm") {
t.Errorf("a helper not there: %v", err)
}
dir := t.TempDir()
if _, err := load("[chan]\nruffle = " + dir + "\n"); err == nil || !strings.Contains(err.Error(), "no ruffle.js") {
t.Errorf("ruffle without its files: %v", err)
}
os.WriteFile(filepath.Join(dir, "ruffle.js"), []byte("//"), 0644)
if c, err := load("[chan]\nruffle = " + dir + "\n"); err != nil || c.Chan.Ruffle != dir {
t.Errorf("ruffle: %v", err)
}
}