diff --git a/spec/examples/examples_spec.lua b/spec/examples/examples_spec.lua index d4efdd2f..35cb8799 100644 --- a/spec/examples/examples_spec.lua +++ b/spec/examples/examples_spec.lua @@ -71,7 +71,7 @@ describe("in-place variables", function() describe("evaluate context across multiple requests", function() local source = open("spec/examples/variables/in_place_variables.http") local req_nodes = parser.get_all_request_nodes(source) - assert.same(3, #req_nodes) + assert(#req_nodes >= 3) local ctx = Context:new() it("example 1", function() local req1 = assert(parser.parse(req_nodes[1], source, ctx)) diff --git a/spec/examples/variables/in_place_variables.http b/spec/examples/variables/in_place_variables.http index 413be820..21900d31 100644 --- a/spec/examples/variables/in_place_variables.http +++ b/spec/examples/variables/in_place_variables.http @@ -15,8 +15,8 @@ GET {{myhost}}/users ### # so `myhost` here is now `example.net` +# check `spec/examples/script/pre_request_script.http` for variable local to each requests GET {{myhost}}/stats ### -# check `spec/examples/script/pre_request_script.http` for variable local to each requests -@myhost=bruh +@myhost=this won't affect above request diff --git a/spec/parser/http_parser_spec.lua b/spec/parser/http_parser_spec.lua index e0f8eeb1..b50958e4 100644 --- a/spec/parser/http_parser_spec.lua +++ b/spec/parser/http_parser_spec.lua @@ -206,8 +206,9 @@ key5 = value5 describe("variables", function() it("parse with variables in header", function() + vim.env["TOKEN"] = "xxx" local source = [[POST https://example.com -X-DATE: {{$date}} +Authorization: Bearer {{TOKEN}} ]] local _, tree = utils.ts_parse_source(source) local req_node = assert(tree:root():child(0)) @@ -215,7 +216,7 @@ X-DATE: {{$date}} assert.not_nil(req) ---@cast req rest.Request assert.same({ - ["x-date"] = { os.date("%Y-%m-%d") }, + ["authorization"] = { "Bearer xxx" }, }, req.headers) end) it("parse with variables in body", function() @@ -223,7 +224,7 @@ X-DATE: {{$date}} local source = [[POST https://example.com { - "name": "{{DATE}}" + "date": "{{DATE}}" } ]] local _, tree = utils.ts_parse_source(source) @@ -234,7 +235,7 @@ X-DATE: {{$date}} assert.same({ __TYPE = "json", data = [[{ - "name": "2024-07-28" + "date": "2024-07-28" }]], }, req.body) end)