MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetStatementRanges

Function TestGetStatementRanges

backend/plugin/parser/mongodb/mongodb_test.go:104–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestGetStatementRanges(t *testing.T) {
105 testCases := []struct {
106 description string
107 statement string
108 wantRanges int
109 }{
110 {
111 description: "single statement",
112 statement: `db.collection.find({})`,
113 wantRanges: 1,
114 },
115 {
116 description: "multiple statements on separate lines",
117 statement: "db.users.find({});\ndb.products.find({})",
118 wantRanges: 2,
119 },
120 {
121 description: "multiline statement",
122 statement: `db.users.aggregate([
123 { $match: { status: "A" } },
124 { $group: { _id: "$cust_id" } }
125])`,
126 wantRanges: 1,
127 },
128 {
129 description: "empty input",
130 statement: "",
131 wantRanges: 0,
132 },
133 }
134
135 for _, tc := range testCases {
136 t.Run(tc.description, func(t *testing.T) {
137 ranges, err := GetStatementRanges(context.Background(), base.StatementRangeContext{}, tc.statement)
138 require.NoError(t, err)
139 require.Len(t, ranges, tc.wantRanges)
140 })
141 }
142}
143
144func TestGetStatementRangesWithHindiCharacters(t *testing.T) {
145 // Test with Hindi characters - ANTLR returns character (rune) offsets, not byte offsets

Callers

nothing calls this directly

Calls 3

LenMethod · 0.80
GetStatementRangesFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected