(t *testing.T)
| 73 | } |
| 74 | |
| 75 | func TestSpoolStdinToTemp_ReadErrorReportsCleanupFailure(t *testing.T) { |
| 76 | readErr := io.ErrUnexpectedEOF |
| 77 | cleanupErr := errors.New("remove failed") |
| 78 | var tempPath string |
| 79 | origRemoveFile := removeFile |
| 80 | removeFile = func(path string) error { |
| 81 | tempPath = path |
| 82 | return cleanupErr |
| 83 | } |
| 84 | t.Cleanup(func() { |
| 85 | removeFile = origRemoveFile |
| 86 | if tempPath != "" { |
| 87 | _ = origRemoveFile(tempPath) |
| 88 | } |
| 89 | }) |
| 90 | |
| 91 | _, _, _, err := spoolStdinToTemp(&failingReader{err: readErr}) |
| 92 | if err == nil { |
| 93 | t.Fatal("expected error for failing reader") |
| 94 | } |
| 95 | if !errors.Is(err, readErr) { |
| 96 | t.Fatalf("error = %v, want read error", err) |
| 97 | } |
| 98 | if !errors.Is(err, cleanupErr) { |
| 99 | t.Fatalf("error = %v, want cleanup error", err) |
| 100 | } |
| 101 | if tempPath == "" { |
| 102 | t.Fatal("expected temp path to be captured") |
| 103 | } |
| 104 | if !strings.Contains(err.Error(), "sensitive stdin data may remain on disk") { |
| 105 | t.Errorf("error = %q, want sensitive-data warning", err.Error()) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestSpoolStdinToTemp_CleanupRemovesFile(t *testing.T) { |
| 110 | r := bytes.NewReader([]byte("data")) |
nothing calls this directly
no test coverage detected