-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#611 - strip comments from meta commands
- Loading branch information
Showing
4 changed files
with
112 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(local {: describe : it} (require :plenary.busted)) | ||
(local assert (require :luassert.assert)) | ||
(local sql (require :conjure.client.sql.stdio)) | ||
|
||
(describe "conjure.client.sql.stdio" | ||
(fn [] | ||
(describe "prep-code" | ||
(fn [] | ||
(it "prepares sql code appropriately" | ||
(fn [] | ||
;; Remove trailing comments from meta commands | ||
;; I may regret this when there's a meta command that takes double dash args... | ||
(assert.same | ||
"foo\n" | ||
(sql.prep-code | ||
{:code "foo -- bar" | ||
:node {:type (fn [] :meta)}})) | ||
|
||
;; Only works on the last line so we don't mangle code, hopefully | ||
(assert.same | ||
"foo -- bar\nsomething\n" | ||
(sql.prep-code | ||
{:code "foo -- bar\nsomething -- quuz" | ||
:node {:type (fn [] :meta)}})) | ||
|
||
;; If the last line has an extra blank line we do nothing, shouldn't really ever happen, but here's the behaviour anyway | ||
(assert.same | ||
"foo -- bar\nsomething -- quux\n\n" | ||
(sql.prep-code | ||
{:code "foo -- bar\nsomething -- quux\n" | ||
:node {:type (fn [] :meta)}})) | ||
|
||
;; If something is a statement it gets a semi colon on the end too | ||
(assert.same | ||
"foo;\n" | ||
(sql.prep-code | ||
{:code "foo -- bar" | ||
:node {:type (fn [] :statement)}})) | ||
|
||
nil)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.