perf: fix any unhandled errors

This commit is contained in:
Antoine Aflalo
2024-09-10 15:10:40 -04:00
parent 72086d658e
commit e798a59a43
5 changed files with 84 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import (
"bytes"
"fmt"
"github.com/belphemur/CBZOptimizer/manga"
"github.com/belphemur/CBZOptimizer/utils/errs"
"os"
"testing"
"time"
@@ -95,7 +96,7 @@ func TestWriteChapterToCBZ(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create temporary file: %v", err)
}
defer os.Remove(tempFile.Name())
defer errs.CaptureGeneric(&err, os.Remove, tempFile.Name(), "failed to remove temporary file")
// Write the chapter to the .cbz file
err = WriteChapterToCBZ(tc.chapter, tempFile.Name())
@@ -108,7 +109,7 @@ func TestWriteChapterToCBZ(t *testing.T) {
if err != nil {
t.Fatalf("Failed to open CBZ file: %v", err)
}
defer r.Close()
defer errs.Capture(&err, r.Close, "failed to close CBZ file")
// Collect the names of the files in the archive
var filesInArchive []string