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

Function TestAnalyzeSQL

pkg/advisor/optimizer_test.go:742–764  ·  view source on GitHub ↗

--------------------------------------------------------------------------- AnalyzeSQL convenience method ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

740// ---------------------------------------------------------------------------
741
742func TestAnalyzeSQL(t *testing.T) {
743 opt := New()
744
745 t.Run("valid SQL succeeds", func(t *testing.T) {
746 result, err := opt.AnalyzeSQL("SELECT id FROM users")
747 if err != nil {
748 t.Fatalf("unexpected error: %v", err)
749 }
750 if result == nil {
751 t.Fatal("expected non-nil result")
752 }
753 if result.Score < 0 || result.Score > 100 {
754 t.Errorf("score %d out of valid range [0, 100]", result.Score)
755 }
756 })
757
758 t.Run("invalid SQL returns error", func(t *testing.T) {
759 _, err := opt.AnalyzeSQL("NOT VALID SQL $$$")
760 if err == nil {
761 t.Error("expected error for invalid SQL")
762 }
763 })
764}
765
766// ---------------------------------------------------------------------------
767// Score and Complexity tests

Callers

nothing calls this directly

Calls 6

RunMethod · 0.80
AnalyzeSQLMethod · 0.80
NewFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected