diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-22 08:23:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-22 08:23:12 +0300 |
| commit | af21fec32c7cf3c15879dba6646a0b5cf19ac583 (patch) | |
| tree | 0073ce15ee7331d11a9794e5a9208b5e23736a2e /internal | |
| parent | d5f5e52db275aa41a0cbaae760eb23ce8e24b160 (diff) | |
Fix gallery PNG copy destination
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/comic/comic_test.go | 16 | ||||
| -rw-r--r-- | internal/comic/runner.go | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/internal/comic/comic_test.go b/internal/comic/comic_test.go index c99bedd..4d0e019 100644 --- a/internal/comic/comic_test.go +++ b/internal/comic/comic_test.go @@ -210,23 +210,27 @@ func TestCopyGalleryPNGsToComicsGallery(t *testing.T) { t.Parallel() root := t.TempDir() - comicDir := filepath.Join(root, "comics", "my-slug") + comicsRoot := filepath.Join(root, "comics") + comicDir := filepath.Join(comicsRoot, "my-slug") if err := os.MkdirAll(comicDir, 0o755); err != nil { t.Fatal(err) } if err := os.WriteFile(filepath.Join(comicDir, "my-slug_gallery_1.png"), []byte("png1"), 0o644); err != nil { t.Fatal(err) } - if err := copyGalleryPNGsToComicsGallery(root, comicDir); err != nil { + if err := copyGalleryPNGsToComicsGallery(comicsRoot, comicDir); err != nil { t.Fatal(err) } - b, err := os.ReadFile(filepath.Join(root, "comics", "gallery", "my-slug_gallery_1.png")) + b, err := os.ReadFile(filepath.Join(comicsRoot, "gallery", "my-slug_gallery_1.png")) if err != nil { t.Fatal(err) } if string(b) != "png1" { t.Fatalf("copied file = %q", b) } + if _, err := os.Stat(filepath.Join(root, "comics", "comics", "gallery", "my-slug_gallery_1.png")); !os.IsNotExist(err) { + t.Fatalf("nested gallery path exists or stat failed unexpectedly: %v", err) + } } func TestGeneratorGenerateFull(t *testing.T) { @@ -424,6 +428,12 @@ func TestArtistAndRunnerEndToEndWithFakes(t *testing.T) { if _, err := os.Stat(filepath.Join(tmpDir, "comics", "assets", "forced-slug", "forced-slug_story.txt")); err != nil { t.Fatalf("story missing: %v", err) } + if _, err := os.Stat(filepath.Join(tmpDir, "comics", "gallery", "forced-slug_gallery_1.png")); err != nil { + t.Fatalf("gallery image missing: %v", err) + } + if _, err := os.Stat(filepath.Join(tmpDir, "comics", "comics", "gallery", "forced-slug_gallery_1.png")); !os.IsNotExist(err) { + t.Fatalf("nested gallery path exists or stat failed unexpectedly: %v", err) + } } func TestNewRunnerUsesRealisticWeightWhenUltraRealisticUnset(t *testing.T) { diff --git a/internal/comic/runner.go b/internal/comic/runner.go index b1381fb..8be8e2c 100644 --- a/internal/comic/runner.go +++ b/internal/comic/runner.go @@ -281,7 +281,7 @@ func (r *Runner) saveTTSPlaceholder(titleSlug, dir string) error { } func copyGalleryPNGsToComicsGallery(outputRoot, comicDir string) error { - destDir := filepath.Join(outputRoot, "comics", "gallery") + destDir := filepath.Join(outputRoot, "gallery") if err := os.MkdirAll(destDir, 0o755); err != nil { return fmt.Errorf("mkdir gallery: %w", err) } |
