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

Function TestFormatParseErrorJSON

cmd/gosqlx/internal/output/json_test.go:201–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestFormatParseErrorJSON(t *testing.T) {
202 testErr := &testError{msg: "tokenization failed: invalid character"}
203
204 jsonData, err := FormatParseErrorJSON(testErr, "SELECT * FROM")
205 if err != nil {
206 t.Fatalf("FormatParseErrorJSON failed: %v", err)
207 }
208
209 var output JSONParseOutput
210 if err := json.Unmarshal(jsonData, &output); err != nil {
211 t.Fatalf("Failed to unmarshal JSON: %v", err)
212 }
213
214 if output.Status != "error" {
215 t.Errorf("Expected status 'error', got '%s'", output.Status)
216 }
217
218 if output.Error == nil {
219 t.Fatal("Expected error to be present")
220 }
221
222 if output.Error.Type != "tokenization" {
223 t.Errorf("Expected error type 'tokenization', got '%s'", output.Error.Type)
224 }
225
226 if output.Results != nil {
227 t.Error("Expected results to be nil on error")
228 }
229}
230
231func TestCategorizeError(t *testing.T) {
232 tests := []struct {

Callers

nothing calls this directly

Calls 4

FormatParseErrorJSONFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected