Skip to content

Commit e04f2c9

Browse files
fix(test): issues from different machine
1 parent 90c46f7 commit e04f2c9

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

lua/rest-nvim/parser/init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ function parser.parse_body(content_type, body_node, source, context)
120120
return
121121
end
122122
---@cast source integer
123-
local basepath = vim.api.nvim_buf_get_name(source):match("(.*)/.*")
123+
local basepath = vim.fs.dirname(vim.api.nvim_buf_get_name(source))
124+
---@diagnostic disable-next-line: undefined-field
125+
basepath = basepath:gsub("^" .. vim.pesc(vim.uv.cwd() .. "/"), "")
124126
path = vim.fs.normalize(vim.fs.joinpath(basepath, path))
125127
body.data = {
126128
name = get_node_field_text(body_node, "name", source),

lua/rest-nvim/utils.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ function utils.parse_http_time(time_str)
100100
sec = tonumber(sec),
101101
isdst = false,
102102
}
103-
return os.time(time_table)
103+
---@diagnostic disable-next-line: param-type-mismatch
104+
local gmt_offset = os.difftime(os.time(), os.time(os.date("!*t")))
105+
return os.time(time_table) + gmt_offset
104106
end
105107

106108
--- Default transformers for statistics

spec/api_spec.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ local function open(path)
1515
return 0
1616
end
1717

18+
---@diagnostic disable-next-line: duplicate-set-field
19+
vim.notify = function () end
20+
1821
describe("parser", function()
1922
it("validate http parser", function()
2023
assert.same("http", vim.treesitter.language.get_lang("http"))

spec/minimum_init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local rest_nvim_dir = vim.fn.fnamemodify(test_dir, ":h")
44
vim.opt.rtp:prepend(vim.fs.normalize("/home/ubuntu/projects/tree-sitter-http"))
55
local parser_dir = "$HOME/.cache/tree-sitter/lib/http.so"
66
if vim.fn.has("macunix") == 1 then
7-
parser_dir = "$HOME/Library/Caches/tree-sitter/lib/http.so"
7+
parser_dir = "$HOME/Library/Caches/tree-sitter/lib/http.dylib"
88
end
99
vim.treesitter.language.add("http", { path = vim.fs.normalize(parser_dir) })
1010
if not vim.treesitter.language.get_lang("http") then

0 commit comments

Comments
 (0)