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

Function TestInvalidNumberError

pkg/errors/builders_test.go:62–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestInvalidNumberError(t *testing.T) {
63 sql := "SELECT * FROM users WHERE age > 18.45.6"
64 location := models.Location{Line: 1, Column: 33}
65
66 err := InvalidNumberError("18.45.6", location, sql)
67
68 if err.Code != ErrCodeInvalidNumber {
69 t.Errorf("InvalidNumberError() code = %v, want %v", err.Code, ErrCodeInvalidNumber)
70 }
71
72 output := err.Error()
73 if !strings.Contains(output, "invalid numeric literal") {
74 t.Errorf("Error should mention invalid numeric literal, got: %s", output)
75 }
76 if !strings.Contains(output, "18.45.6") {
77 t.Errorf("Error should include the invalid number, got: %s", output)
78 }
79}
80
81func TestUnexpectedTokenError(t *testing.T) {
82 sql := "SELECT * FORM users"

Callers

nothing calls this directly

Calls 3

InvalidNumberErrorFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected