TestErrorPathsIntegration tests error handling improvements
(t *testing.T)
| 353 | |
| 354 | // TestErrorPathsIntegration tests error handling improvements |
| 355 | func TestErrorPathsIntegration(t *testing.T) { |
| 356 | t.Run("InvalidSQLPattern", func(t *testing.T) { |
| 357 | // Test that non-SQL input is properly rejected |
| 358 | _, err := DetectAndReadInput("just some random text that is not SQL") |
| 359 | if err == nil { |
| 360 | t.Error("Expected error for non-SQL input, got success") |
| 361 | } |
| 362 | if !strings.Contains(err.Error(), "does not appear to be valid SQL") { |
| 363 | t.Errorf("Expected SQL validation error, got: %v", err) |
| 364 | } |
| 365 | }) |
| 366 | |
| 367 | t.Run("EmptyFileHandling", func(t *testing.T) { |
| 368 | tmpDir := t.TempDir() |
| 369 | emptyFile := filepath.Join(tmpDir, "empty.sql") |
| 370 | err := os.WriteFile(emptyFile, []byte(""), 0644) |
| 371 | if err != nil { |
| 372 | t.Fatalf("Failed to create empty file: %v", err) |
| 373 | } |
| 374 | |
| 375 | _, err = DetectAndReadInput(emptyFile) |
| 376 | if err == nil { |
| 377 | t.Error("Expected error for empty file, got success") |
| 378 | } |
| 379 | if !strings.Contains(err.Error(), "empty") { |
| 380 | t.Errorf("Expected empty file error, got: %v", err) |
| 381 | } |
| 382 | }) |
| 383 | } |
nothing calls this directly
no test coverage detected