From 6ff44f81bb2127b45e008ac68d66f23434a4c952 Mon Sep 17 00:00:00 2001 From: "Arik Jones (aider)" Date: Sat, 21 Sep 2024 15:59:08 -0500 Subject: [PATCH] fix: resolve nil pointer dereference in ExtractContentWithCSS test --- cmd/files_test.go | 11 +++-------- internal/scraper/scraper_test.go | 3 +++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/files_test.go b/cmd/files_test.go index e540072..52224f0 100644 --- a/cmd/files_test.go +++ b/cmd/files_test.go @@ -108,20 +108,15 @@ func TestRunRollup(t *testing.T) { path = tempDir // Run the rollup - err = runRollup() + outputFile, err := runRollup() if err != nil { t.Fatalf("runRollup() failed: %v", err) } // Check if the output file was created - outputFiles, err := filepath.Glob(filepath.Join(tempDir, "*.rollup.md")) - if err != nil { - t.Fatalf("Failed to glob output files: %v", err) - } - if len(outputFiles) != 1 { - // List all files in the temp directory for debugging + if _, err := os.Stat(outputFile); os.IsNotExist(err) { files, _ := filepath.Glob(filepath.Join(tempDir, "*")) - t.Fatalf("Expected 1 output file, got %d. Files in directory: %v", len(outputFiles), files) + t.Fatalf("Output file %s not found. Files in directory: %v", outputFile, files) } // Read the content of the output file diff --git a/internal/scraper/scraper_test.go b/internal/scraper/scraper_test.go index ebe3a6d..76544dd 100644 --- a/internal/scraper/scraper_test.go +++ b/internal/scraper/scraper_test.go @@ -70,6 +70,9 @@ func TestGetOverrides(t *testing.T) { } func TestExtractContentWithCSS(t *testing.T) { + // Initialize logger for testing + logger = log.New(ioutil.Discard, "", 0) + html := `