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

Function TestExtractErrorCode

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

Source from the content-addressed store, hash-verified

476}
477
478func TestExtractErrorCode(t *testing.T) {
479 structErr := NewError(ErrCodeUnexpectedToken, "test", models.Location{})
480 simpleErr := fmt.Errorf("simple error")
481
482 // Test with structured error
483 code, ok := ExtractErrorCode(structErr)
484 if !ok {
485 t.Error("ExtractErrorCode() should return true for structured error")
486 }
487 if code != ErrCodeUnexpectedToken {
488 t.Errorf("ExtractErrorCode() code = %v, want %v", code, ErrCodeUnexpectedToken)
489 }
490
491 // Test with simple error
492 _, ok = ExtractErrorCode(simpleErr)
493 if ok {
494 t.Error("ExtractErrorCode() should return false for simple error")
495 }
496}
497
498func TestFormatErrorWithUnicode(t *testing.T) {
499 tests := []struct {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected