(t *testing.T)
| 329 | } |
| 330 | |
| 331 | func TestScanSQL_CommentPatterns(t *testing.T) { |
| 332 | scanner := NewScanner() |
| 333 | |
| 334 | testCases := []struct { |
| 335 | sql string |
| 336 | shouldFind bool |
| 337 | description string |
| 338 | }{ |
| 339 | {"SELECT * FROM users WHERE id = 1 --", true, "single-line comment at end"}, |
| 340 | {"SELECT * FROM users WHERE id = '1'--", true, "comment after quote"}, |
| 341 | {"SELECT * FROM users /* WHERE id = 1 */", true, "block comment"}, |
| 342 | {"SELECT * FROM users", false, "no comments"}, |
| 343 | } |
| 344 | |
| 345 | for _, tc := range testCases { |
| 346 | result := scanner.ScanSQL(tc.sql) |
| 347 | hasCommentFinding := false |
| 348 | for _, f := range result.Findings { |
| 349 | if f.Pattern == PatternComment { |
| 350 | hasCommentFinding = true |
| 351 | break |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | if tc.shouldFind && !hasCommentFinding { |
| 356 | t.Errorf("expected comment pattern in: %s", tc.description) |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | func TestScanSQL_TimeBasedPatterns(t *testing.T) { |
| 362 | scanner := NewScanner() |
nothing calls this directly
no test coverage detected