| 314 | } |
| 315 | |
| 316 | func TestHintFileWriterErrorHandling(t *testing.T) { |
| 317 | t.Run("Write nil entry", func(t *testing.T) { |
| 318 | writer := &HintFileWriter{} |
| 319 | err := writer.Write(nil) |
| 320 | if err != ErrHintFileEntryInvalid { |
| 321 | t.Errorf("Expected ErrHintFileEntryInvalid, got %v", err) |
| 322 | } |
| 323 | }) |
| 324 | |
| 325 | t.Run("Create file in non-existent directory", func(t *testing.T) { |
| 326 | writer := &HintFileWriter{} |
| 327 | writerPath := filepath.Join("non", "existent", "path", "test.hint") |
| 328 | err := writer.Create(writerPath) |
| 329 | if err == nil { |
| 330 | t.Error("Expected error when creating file in non-existent directory") |
| 331 | } |
| 332 | }) |
| 333 | |
| 334 | t.Run("Sync without file", func(t *testing.T) { |
| 335 | writer := &HintFileWriter{} |
| 336 | err := writer.Sync() |
| 337 | if err != nil { |
| 338 | t.Errorf("Unexpected error when syncing without file: %v", err) |
| 339 | } |
| 340 | }) |
| 341 | |
| 342 | t.Run("Close without file", func(t *testing.T) { |
| 343 | writer := &HintFileWriter{} |
| 344 | err := writer.Close() |
| 345 | if err != nil { |
| 346 | t.Errorf("Unexpected error when closing without file: %v", err) |
| 347 | } |
| 348 | }) |
| 349 | } |
| 350 | |
| 351 | func TestHintFileReaderErrorHandling(t *testing.T) { |
| 352 | t.Run("Open non-existent file", func(t *testing.T) { |