summaryrefslogtreecommitdiffstats
path: root/test/test_sql_anno.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 17:44:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 17:44:55 +0000
commit5068d34c08f951a7ea6257d305a1627b09a95817 (patch)
tree08213e2be853396a3b07ce15dbe222644dcd9a89 /test/test_sql_anno.sh
parentInitial commit. (diff)
downloadlnav-5068d34c08f951a7ea6257d305a1627b09a95817.tar.xz
lnav-5068d34c08f951a7ea6257d305a1627b09a95817.zip
Adding upstream version 0.11.1.upstream/0.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--test/test_sql_anno.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/test_sql_anno.sh b/test/test_sql_anno.sh
new file mode 100644
index 0000000..e09c312
--- /dev/null
+++ b/test/test_sql_anno.sh
@@ -0,0 +1,50 @@
+#! /bin/bash
+
+# basic query
+run_cap_test ./drive_sql_anno "SELECT * FROM FOO"
+
+# no help for keyword flag
+run_cap_test ./drive_sql_anno "TABLE"
+
+# nested function calls
+run_cap_test ./drive_sql_anno "SELECT foo(bar())"
+
+# nested function calls
+run_cap_test ./drive_sql_anno "SELECT foo(bar())" 2
+
+# caret in keyword whitespace
+run_cap_test ./drive_sql_anno "SELECT lower(abc)" 9
+
+# caret in function whitespace
+run_cap_test ./drive_sql_anno "SELECT lower( abc )" 14
+
+# caret in unfinished function call
+run_cap_test ./drive_sql_anno "SELECT lower(abc" 16
+
+# caret on the outer function
+run_cap_test ./drive_sql_anno "SELECT instr(lower(abc), '123')" 9
+
+# caret on a nested function
+run_cap_test ./drive_sql_anno "SELECT instr(lower(abc), '123')" 15
+
+# caret on a flag
+run_cap_test ./drive_sql_anno "SELECT instr(lower(abc), '123') FROM bar" 30
+
+# multiple help hits
+run_cap_test ./drive_sql_anno "CREATE" 2
+
+# string vs ident
+run_cap_test ./drive_sql_anno "SELECT 'hello, world!' FROM \"my table\""
+
+# math
+run_cap_test ./drive_sql_anno "SELECT (1 + 2) AS three"
+
+run_cap_test ./drive_sql_anno "SELECT (1.5 + 2.2) AS decim"
+
+# subqueries
+run_cap_test ./drive_sql_anno "SELECT * FROM (SELECT foo, bar FROM baz)"
+
+run_cap_test ./drive_sql_anno \
+ "SELECT * from vmw_log, regexp_capture(log_body, '--> /SessionStats/SessionPool/Session/(?<line>[abc]+)')"
+
+run_cap_test ./drive_sql_anno "SELECT * FROM foo.bar"