(t *testing.T)
| 80 | } |
| 81 | |
| 82 | func TestError_WithContext(t *testing.T) { |
| 83 | sql := "SELECT * FORM users" |
| 84 | location := models.Location{Line: 1, Column: 10} |
| 85 | |
| 86 | err := NewError(ErrCodeExpectedToken, "expected FROM, got FORM", location) |
| 87 | err.WithContext(sql, 4) // Highlight "FORM" (4 characters) |
| 88 | |
| 89 | output := err.Error() |
| 90 | |
| 91 | // Should contain the SQL line |
| 92 | if !strings.Contains(output, sql) { |
| 93 | t.Errorf("Error output should contain SQL line, got: %s", output) |
| 94 | } |
| 95 | |
| 96 | // Should contain position indicator |
| 97 | if !strings.Contains(output, "^") { |
| 98 | t.Errorf("Error output should contain position indicator (^), got: %s", output) |
| 99 | } |
| 100 | |
| 101 | // Should highlight the correct length |
| 102 | if !strings.Contains(output, "^^^^") { |
| 103 | t.Errorf("Error output should highlight 4 characters (^^^^), got: %s", output) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func TestError_WithHint(t *testing.T) { |
| 108 | err := NewError(ErrCodeUnexpectedToken, "unexpected token", models.Location{Line: 1, Column: 5}) |
nothing calls this directly
no test coverage detected