diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-27 09:18:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-27 09:18:52 +0300 |
| commit | 47d69cb998a447eea662ad1075f9d002dd875443 (patch) | |
| tree | 1fa586fc4f7e5fae2ce9badfa05679c0fee9dcb3 /internal/processor/processor_test.go | |
| parent | 626ff3ae7d43cfc2ec3f2554d340b40f4a5c0586 (diff) | |
Add context.Context to I/O-bound public APIs (generator.Run, processor.Run, atom.Generate, syncOutput)
- generator.Run(ctx, cfg) – ctx passed through to atom.Generate
- processor.Run(ctx, cfg) – signature updated for cancellation propagation
- atom.Generate(ctx, posts, cfg) – accepts ctx for future cancellation
- syncOutput(ctx, cfg) – rsync subprocesses now use exec.CommandContext
- Updated all call sites in tests, cmd/snonux/main.go, and integration tests
- All call sites pass context.Background() / context.TODO()
All tests pass: go test ./...
Diffstat (limited to 'internal/processor/processor_test.go')
| -rw-r--r-- | internal/processor/processor_test.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/internal/processor/processor_test.go b/internal/processor/processor_test.go index 418fb95..b5e8f20 100644 --- a/internal/processor/processor_test.go +++ b/internal/processor/processor_test.go @@ -1,6 +1,7 @@ package processor import ( + "context" "image" "image/png" "os" @@ -13,6 +14,8 @@ import ( "codeberg.org/snonux/snonux/internal/post" ) +var ctx = context.Background() //nolint:gochecknoglobals // test-only top-level helper used by every test in the file + func TestRun_processesTxt(t *testing.T) { t.Parallel() @@ -23,7 +26,7 @@ func TestRun_processesTxt(t *testing.T) { } cfg := &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x.test"} - n, err := Run(cfg) + n, err := Run(ctx, cfg) if err != nil { t.Fatalf("Run: %v", err) } @@ -57,7 +60,7 @@ func TestRun_unsupportedExt(t *testing.T) { t.Fatal(err) } - _, err := Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + _, err := Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err == nil { t.Fatal("expected error") } @@ -66,7 +69,7 @@ func TestRun_unsupportedExt(t *testing.T) { func TestRun_readInputDirFails(t *testing.T) { t.Parallel() - _, err := Run(&config.Config{InputDir: "/nonexistent/inbox/xyz", OutputDir: t.TempDir(), BaseURL: "https://x"}) + _, err := Run(ctx, &config.Config{InputDir: "/nonexistent/inbox/xyz", OutputDir: t.TempDir(), BaseURL: "https://x"}) if err == nil { t.Fatal("expected error") } @@ -89,7 +92,7 @@ func TestRun_png(t *testing.T) { } f.Close() - n, err := Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + n, err := Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err != nil { t.Fatalf("Run: %v", err) } @@ -107,7 +110,7 @@ func TestRun_mp3(t *testing.T) { t.Fatal(err) } - n, err := Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + n, err := Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err != nil { t.Fatalf("Run: %v", err) } @@ -125,7 +128,7 @@ func TestRun_markdown(t *testing.T) { t.Fatal(err) } - n, err := Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + n, err := Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err != nil { t.Fatalf("Run: %v", err) } @@ -216,7 +219,7 @@ text` t.Fatal(err) } - n, err := Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + n, err := Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err != nil { t.Fatalf("Run: %v", err) } @@ -264,7 +267,7 @@ func TestRun_twoMarkdownsClaimingSameImageFails(t *testing.T) { t.Fatal(err) } - _, err = Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + _, err = Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err == nil { t.Fatal("expected error when two markdowns claim the same image") } @@ -307,7 +310,7 @@ func TestRun_duplicateImageClaimsInSameMarkdownAllowed(t *testing.T) { t.Fatal(err) } - n, err := Run(&config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) + n, err := Run(ctx, &config.Config{InputDir: in, OutputDir: out, BaseURL: "https://x"}) if err != nil { t.Fatalf("Run: %v", err) } |
