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

Function TestIsCode

pkg/errors/errors_test.go:139–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestIsCode(t *testing.T) {
140 err := NewError(ErrCodeExpectedToken, "test", models.Location{})
141
142 if !IsCode(err, ErrCodeExpectedToken) {
143 t.Error("IsCode() should return true for matching code")
144 }
145
146 if IsCode(err, ErrCodeUnexpectedToken) {
147 t.Error("IsCode() should return false for non-matching code")
148 }
149
150 // Test with non-structured error
151 if IsCode(nil, ErrCodeExpectedToken) {
152 t.Error("IsCode() should return false for nil error")
153 }
154}
155
156func TestGetCode(t *testing.T) {
157 err := NewError(ErrCodeUnexpectedToken, "test", models.Location{})

Callers

nothing calls this directly

Calls 3

IsCodeFunction · 0.85
NewErrorFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected