From 048edb8e011ce2e7e6910e305dc9a3242d319831 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 23:10:13 -0300 Subject: tests: unit test updates --- spec/unit/fetch_spec.lua | 2 +- spec/unit/fun_spec.lua | 11 ----------- spec/unit/rockspecs_spec.lua | 14 ++++++++------ spec/unit/util_spec.lua | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) (limited to 'spec') diff --git a/spec/unit/fetch_spec.lua b/spec/unit/fetch_spec.lua index bea50d78..85d89b6c 100644 --- a/spec/unit/fetch_spec.lua +++ b/spec/unit/fetch_spec.lua @@ -55,7 +55,7 @@ describe("luarocks fetch #unit", function() fdr:close() fdw:close() - return true, destfile + return destfile end runner = require("luacov.runner") diff --git a/spec/unit/fun_spec.lua b/spec/unit/fun_spec.lua index bffb60d7..774aa937 100644 --- a/spec/unit/fun_spec.lua +++ b/spec/unit/fun_spec.lua @@ -58,17 +58,6 @@ describe("luarocks.fun #unit", function() end) end) - describe("fun.traverse", function() - it("recursively applies a function to each element in a given table and returns the results in a new table", function() - local t - - t = {1, 2, {3, 4, {5, 6}}} - assert.same(fun.traverse(t, addOne), {2, 3, {4, 5, {6, 7}}}) - t = {1, 2, {}, {1, {}, 2}} - assert.same(fun.traverse(t, addOne), {2, 3, {}, {2, {}, 3}}) - end) - end) - describe("fun.filter", function() it("filters the elements in the given table and returns the result in a new table", function() local t diff --git a/spec/unit/rockspecs_spec.lua b/spec/unit/rockspecs_spec.lua index 7eb033c8..2357a2a1 100644 --- a/spec/unit/rockspecs_spec.lua +++ b/spec/unit/rockspecs_spec.lua @@ -28,7 +28,9 @@ describe("luarocks.rockspecs #unit", function() assert(rockspec == out) assert.same(rockspec.build_dependencies, { - { name = "luarocks-build-foo", constraints = {} }, + queries = { + { name = "luarocks-build-foo", constraints = {} } + }, }) end) @@ -53,9 +55,9 @@ describe("luarocks.rockspecs #unit", function() assert(rockspec == out) - assert.same(rockspec.build_dependencies, { + assert.same(rockspec.build_dependencies, { "luarocks-build-cpp >= 1.0", queries = { { name = "luarocks-build-cpp", constraints = { { op = ">=", version = { string = "1.0", 1, 0 } } } }, - }) + }}) end) it("does not add a build dependency for 'none' build type", function() @@ -75,7 +77,7 @@ describe("luarocks.rockspecs #unit", function() local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick) assert(rockspec == out) - assert.same(rockspec.build_dependencies, {}) + assert.same(rockspec.build_dependencies, { queries = {}}) end) it("does not add a build dependency for 'module' build type", function() @@ -95,7 +97,7 @@ describe("luarocks.rockspecs #unit", function() local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick) assert(rockspec == out) - assert.same(rockspec.build_dependencies, {}) + assert.same(rockspec.build_dependencies, { queries = {}}) end) for d in lfs.dir(test_env.testing_paths.src_dir .. "/luarocks/build") do @@ -118,7 +120,7 @@ describe("luarocks.rockspecs #unit", function() local out = rockspecs.from_persisted_table(filename, rockspec, globals, quick) assert(rockspec == out) - assert.same(rockspec.build_dependencies, {}) + assert.same(rockspec.build_dependencies, { queries = {}}) end) end end diff --git a/spec/unit/util_spec.lua b/spec/unit/util_spec.lua index 8b234b2e..5b19bb34 100644 --- a/spec/unit/util_spec.lua +++ b/spec/unit/util_spec.lua @@ -83,8 +83,8 @@ describe("luarocks.util #unit", function() assert.are.same({}, collect(util.sortedpairs({}, {"k1", "k2"}))) assert.are.same({ {"k3", "v3"}, - {"k2", "v2", {"sub order"}}, {"k1", "v1"}, + {"k2", "v2"}, {"k4", "v4"}, {"k5", "v5"}, }, collect(util.sortedpairs({ -- cgit v1.2.3-55-g6feb