diff --git a/Makefile b/Makefile index 7d6e9911..caacea91 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,13 @@ ensure-test-deps: @mkdir -p vendor @if test ! -d ./vendor/plenary.nvim; then git clone git@github.com:nvim-lua/plenary.nvim.git ./vendor/plenary.nvim/; fi @if test ! -d ./vendor/luassert; then git clone git@github.com:Olivine-Labs/luassert.git ./vendor/luassert/; fi + @if test ! -d ./vendor/sqlite; then git clone git@github.com:kkharji/sqlite.lua.git ./vendor/sqlite/; fi .PHONY: update-test-deps update-test-deps: ensure-test-deps @cd ./vendor/plenary.nvim/ && git pull && cd .. @cd ./vendor/luassert/ && git pull && cd .. + @cd ./vendor/sqlite/ && git pull && cd .. .PHONY: ensure-doc-deps ensure-doc-deps: diff --git a/tests/legendary/to_bytes_spec.lua b/tests/legendary/to_bytes_spec.lua new file mode 100644 index 00000000..e155b66c --- /dev/null +++ b/tests/legendary/to_bytes_spec.lua @@ -0,0 +1,16 @@ +local assert = require('luassert') +local wrapper = require('legendary.api.db.wrapper') + +describe('to_bytes function', function() + local test_data = { + ['test string'] = '11610111511632115116114105110103', + ['with icons 󰊢'] = '119105116104321059911111011532243176138162238158168238153135', + ['with quote chars \'"'] = '11910511610432113117111116101329910497114115323934', + ['with emoji 🦀'] = '1191051161043210110911110610532240159166128', + } + for input, output in pairs(test_data) do + it(string.format('for input `%s`, output should be "%s"', input, output), function() + assert.are.same(wrapper.to_bytes(input), output) + end) + end +end) diff --git a/tests/testrc.lua b/tests/testrc.lua index a28a63f6..5483750d 100644 --- a/tests/testrc.lua +++ b/tests/testrc.lua @@ -2,6 +2,7 @@ vim.cmd([[ set rtp+=. set rtp+=vendor/plenary.nvim set rtp+=vendor/luassert + set rtp+=vendor/sqlite runtime plugin/plenary.vim ]]) require('plenary.busted')