MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestGetQuerySpan

Function TestGetQuerySpan

backend/plugin/parser/mongodb/query_span_test.go:63–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestGetQuerySpan(t *testing.T) {
64 tests := []struct {
65 description string
66 statement string
67 wantType base.QueryType
68 }{
69 {
70 description: "find is Select",
71 statement: `db.users.find({})`,
72 wantType: base.Select,
73 },
74 {
75 description: "findOne is Select",
76 statement: `db.users.findOne({name: "John"})`,
77 wantType: base.Select,
78 },
79 {
80 description: "insertOne is DML",
81 statement: `db.users.insertOne({name: "John"})`,
82 wantType: base.DML,
83 },
84 {
85 description: "insertMany is DML",
86 statement: `db.users.insertMany([{name: "A"}, {name: "B"}])`,
87 wantType: base.DML,
88 },
89 {
90 description: "updateOne is DML",
91 statement: `db.users.updateOne({name: "John"}, {$set: {age: 30}})`,
92 wantType: base.DML,
93 },
94 {
95 description: "deleteOne is DML",
96 statement: `db.users.deleteOne({name: "John"})`,
97 wantType: base.DML,
98 },
99 {
100 description: "createCollection is DDL",
101 statement: `db.createCollection("test")`,
102 wantType: base.DDL,
103 },
104 {
105 description: "dropDatabase is DDL",
106 statement: `db.dropDatabase()`,
107 wantType: base.DDL,
108 },
109 {
110 description: "createIndex is DDL",
111 statement: `db.users.createIndex({name: 1})`,
112 wantType: base.DDL,
113 },
114 {
115 description: "drop collection is DDL",
116 statement: `db.users.drop()`,
117 wantType: base.DDL,
118 },
119 {
120 description: "find with explain suffix is Explain",

Callers

nothing calls this directly

Calls 3

GetQuerySpanFunction · 0.70
EqualMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected