From 42c5886178e5ca0cf4796ad45b1594087cb8da4e Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 6 Jun 2022 15:43:58 -0300 Subject: tests: tests for util.variable_substitutions --- spec/util_spec.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'spec') diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 5aa49b4c..0c2d620e 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -72,6 +72,31 @@ describe("luarocks.util #unit", function() runner.shutdown() end) + describe("util.variable_substitutions", function() + it("replaces variables", function() + local t = { + ["hello"] = "$(KIND) world", + } + util.variable_substitutions(t, { + ["KIND"] = "happy", + }) + assert.are.same({ + ["hello"] = "happy world", + }, t) + end) + + it("missing variables are empty", function() + local t = { + ["hello"] = "$(KIND) world", + } + util.variable_substitutions(t, { + }) + assert.are.same({ + ["hello"] = " world", + }, t) + end) + end) + describe("util.sortedpairs", function() local function collect(iter, state, var) local collected = {} -- cgit v1.2.3-55-g6feb