MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestExtractLocation

Function TestExtractLocation

pkg/errors/formatter_test.go:457–476  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

455}
456
457func TestExtractLocation(t *testing.T) {
458 location := models.Location{Line: 5, Column: 10}
459 structErr := NewError(ErrCodeUnexpectedToken, "test", location)
460 simpleErr := fmt.Errorf("simple error")
461
462 // Test with structured error
463 gotLoc, ok := ExtractLocation(structErr)
464 if !ok {
465 t.Error("ExtractLocation() should return true for structured error")
466 }
467 if gotLoc != location {
468 t.Errorf("ExtractLocation() location = %v, want %v", gotLoc, location)
469 }
470
471 // Test with simple error
472 _, ok = ExtractLocation(simpleErr)
473 if ok {
474 t.Error("ExtractLocation() should return false for simple error")
475 }
476}
477
478func TestExtractErrorCode(t *testing.T) {
479 structErr := NewError(ErrCodeUnexpectedToken, "test", models.Location{})

Callers

nothing calls this directly

Calls 4

ExtractLocationFunction · 0.85
NewErrorFunction · 0.70
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected