MCPcopy Create free account
hub / github.com/datastax/cql-proxy / TestParser

Function TestParser

parser/parser_test.go:27–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestParser(t *testing.T) {
28 var tests = []struct {
29 keyspace string
30 query string
31 handled bool
32 idempotent bool
33 stmt Statement
34 hasError bool
35 }{
36 {"", "SELECT key, rpc_address AS address, count(*) FROM system.local", true, true, &SelectStatement{
37 Keyspace: "system",
38 Table: "local",
39 Selectors: []Selector{
40 &IDSelector{Name: "key"},
41 &AliasSelector{Alias: "address", Selector: &IDSelector{Name: "rpc_address"}},
42 &CountFuncSelector{Arg: "*"},
43 },
44 }, false},
45 {"system", "SELECT count(*) FROM local", true, true, &SelectStatement{
46 Keyspace: "system",
47 Table: "local",
48 Selectors: []Selector{
49 &CountFuncSelector{Arg: "*"},
50 },
51 }, false},
52 {"system", "SELECT count(*) FROM \"local\"", true, true, &SelectStatement{
53 Keyspace: "system",
54 Table: "local",
55 Selectors: []Selector{
56 &CountFuncSelector{Arg: "*"},
57 },
58 }, false},
59 {"", "SELECT count(*) FROM system.peers", true, true, &SelectStatement{
60 Keyspace: "system",
61 Table: "peers",
62 Selectors: []Selector{
63 &CountFuncSelector{Arg: "*"},
64 },
65 }, false},
66 {"", "SELECT count(*) FROM \"system\".\"peers\"", true, true, &SelectStatement{
67 Keyspace: "system",
68 Table: "peers",
69 Selectors: []Selector{
70 &CountFuncSelector{Arg: "*"},
71 },
72 }, false},
73 {"system", "SELECT count(*) FROM peers", true, true, &SelectStatement{
74 Keyspace: "system",
75 Table: "peers",
76 Selectors: []Selector{
77 &CountFuncSelector{Arg: "*"},
78 },
79 }, false},
80 {"", "SELECT count(*) FROM system.peers_v2", true, true, &SelectStatement{
81 Keyspace: "system",
82 Table: "peers_v2",
83 Selectors: []Selector{
84 &CountFuncSelector{Arg: "*"},

Callers

nothing calls this directly

Calls 3

IsQueryHandledFunction · 0.85
IdentifierFromStringFunction · 0.85
IsQueryIdempotentFunction · 0.85

Tested by

no test coverage detected