Skip to content

Commit

Permalink
rework(DB): naming like in prisma.io
Browse files Browse the repository at this point in the history
The reasoning behind this is to make it easier to
find code that does updates, or just fetches a single item,
or fetches the whole dataset.

Additionally add global data which is currently only used for
.replay().

.replay() should enable the user to run the last command in any buffer,
not only in .http or .rest buffers.
  • Loading branch information
gorillamoe committed Sep 7, 2024
1 parent ee83f98 commit 321170b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/kulala/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ M.default_contenttype = {
pathresolver = nil,
}

M.options = {}
M.options = M.defaults

M.setup = function(config)
M.options = vim.tbl_deep_extend("force", M.defaults, config or {})
Expand Down
24 changes: 24 additions & 0 deletions tests/parser/db_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local DB = require("kulala.db")

describe("db scoped", function()
it("should not leak into other buffers", function()
vim.cmd("new")
local buf1 = vim.api.nvim_get_current_buf()
DB.update().key1 = "value1"
assert.equal(DB.find_unique("key1"), "value1")

vim.cmd("new")
local buf2 = vim.api.nvim_get_current_buf()
DB.update().key2 = "value2"
assert.equal(DB.find_unique("key1"), nil)
assert.equal(DB.find_unique("key2"), "value2")

vim.api.nvim_set_current_buf(buf1)
assert.equal(DB.find_unique("key1"), "value1")
assert.equal(DB.find_unique("key2"), nil)

vim.api.nvim_set_current_buf(buf2)
assert.equal(DB.find_unique("key1"), nil)
assert.equal(DB.find_unique("key2"), "value2")
end)
end)

0 comments on commit 321170b

Please sign in to comment.