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

Function TestCompletion

backend/plugin/parser/trino/completion_test.go:41–140  ·  view source on GitHub ↗

TestCompletion exercises the omni-backed Trino completer through the public Completion entry point. DIVERGENCE FROM THE LEGACY ANTLR COMPLETER (intentional, documented): The previous Completion was a ~1730-line CodeCompletionCore (c3) port. The omni Trino completer is explicitly NOT a c3 port (see

(t *testing.T)

Source from the content-addressed store, hash-verified

39// These cases therefore assert the candidate *set* (Text, Type) the omni
40// completer actually returns, rather than the legacy YAML fixture.
41func TestCompletion(t *testing.T) {
42 type want struct {
43 text string
44 typ base.CandidateType
45 }
46 tests := []struct {
47 description string
48 input string // caret marked by "|"
49 // wantPresent candidates that MUST appear.
50 wantPresent []want
51 // wantAbsentText candidate texts that must NOT appear (any type).
52 wantAbsentText []string
53 }{
54 {
55 description: "FROM offers catalogs, schemas, and current-schema tables",
56 input: "SELECT * FROM |",
57 wantPresent: []want{
58 {"company", base.CandidateTypeDatabase},
59 {"school", base.CandidateTypeDatabase},
60 {"dbo", base.CandidateTypeSchema},
61 {"myschema", base.CandidateTypeSchema},
62 {"address", base.CandidateTypeTable},
63 {"employees", base.CandidateTypeTable},
64 },
65 },
66 {
67 description: "Schema-qualified FROM offers that schema's tables",
68 input: "SELECT * FROM dbo.|",
69 wantPresent: []want{
70 {"address", base.CandidateTypeTable},
71 {"employees", base.CandidateTypeTable},
72 },
73 wantAbsentText: []string{"salarylevel"},
74 },
75 {
76 description: "Schema-qualified FROM for a non-current schema",
77 input: "SELECT * FROM myschema.|",
78 wantPresent: []want{
79 {"salarylevel", base.CandidateTypeTable},
80 },
81 },
82 {
83 description: "SELECT column context offers in-scope columns",
84 input: "SELECT | FROM Employees",
85 wantPresent: []want{
86 {"id", base.CandidateTypeColumn},
87 {"name", base.CandidateTypeColumn},
88 },
89 },
90 {
91 description: "WHERE column context offers in-scope columns",
92 input: "SELECT * FROM Employees WHERE |",
93 wantPresent: []want{
94 {"id", base.CandidateTypeColumn},
95 {"name", base.CandidateTypeColumn},
96 },
97 },
98 {

Callers

nothing calls this directly

Calls 6

getCaretPositionFunction · 0.70
CompletionFunction · 0.70
hasCandidateFunction · 0.70
candidateSummaryFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected