@@ -12,8 +12,14 @@ func TestFileExists(t *testing.T) {
1212 if err != nil {
1313 t .Fatalf ("Failed to create temporary file: %v" , err )
1414 }
15- defer os .Remove (tempFile .Name ())
16- defer tempFile .Close ()
15+ defer func () {
16+ if err := tempFile .Close (); err != nil {
17+ t .Logf ("Failed to close temporary file: %v" , err )
18+ }
19+ if err := os .Remove (tempFile .Name ()); err != nil {
20+ t .Logf ("Failed to remove temporary file: %v" , err )
21+ }
22+ }()
1723
1824 // Test cases
1925 tests := []struct {
@@ -52,25 +58,29 @@ func TestFileExists(t *testing.T) {
5258func TestOutputPathGeneration (t * testing.T ) {
5359 // This is a mock test to demonstrate how we would test the output path generation
5460 // In a real test, we would need to mock time.Now() or use dependency injection
55-
61+
5662 // Create a temporary directory for testing
5763 tempDir , err := os .MkdirTemp ("" , "pdf-joiner-test" )
5864 if err != nil {
5965 t .Fatalf ("Failed to create temporary directory: %v" , err )
6066 }
61- defer os .RemoveAll (tempDir )
62-
67+ defer func () {
68+ if err := os .RemoveAll (tempDir ); err != nil {
69+ t .Logf ("Failed to remove temporary directory: %v" , err )
70+ }
71+ }()
72+
6373 // Test that we can create directories for output
6474 testOutputPath := filepath .Join (tempDir , "subdir" , "output.pdf" )
6575 outputDir := filepath .Dir (testOutputPath )
66-
76+
6777 err = os .MkdirAll (outputDir , 0755 )
6878 if err != nil {
6979 t .Errorf ("Failed to create output directory: %v" , err )
7080 }
71-
81+
7282 // Verify the directory was created
7383 if _ , err := os .Stat (outputDir ); os .IsNotExist (err ) {
7484 t .Errorf ("Output directory was not created: %v" , err )
7585 }
76- }
86+ }
0 commit comments