Verified Commit 965a6b71 authored by Karel Koci's avatar Karel Koci 🤘

New tests for files/directories collisions check and root node fix

parent 248ee62e
......@@ -589,7 +589,7 @@ function collision_check(current_status, remove_pkgs, add_pkgs)
key, one of string "to-remove", "existing" or "new" under "when" key. And
both have full path under "path" key.
--]]
local files_tree = {}
local files_tree = {path = "/"}
-- First returned result. Table with collisions. Key is collision path and value is table with packages names as keys and "when" as values.
local collisions = {}
-- Second returned result. We fill this with nodes we want to remove before given package is merged to file system
......
......@@ -461,20 +461,19 @@ function test_collisions()
-- A collision between two new packages
test_pkg['another'] = test_pkg['package']
local col, erem, rem = B.collision_check(status, {['kmod-usb-storage'] = true}, test_pkg)
assert_not_equal({
["/etc/modules.d/usb-storage"] = true
}, utils.map(col, function (k) return k, true end))
assert_table_equal({
["package"] = "new",
["another"] = "new"
}, col["/etc/modules.d/usb-storage"])
["/etc/modules.d/usb-storage"] = {
["package"] = "new",
["another"] = "new"
}
}, col)
assert_table_equal({}, erem)
assert_table_equal({
["/lib/modules/3.18.21-70ea6b9a4b789c558ac9d579b5c1022f-10/usb-storage.ko"] = true,
["/etc/modules-boot.d/usb-storage"] = true
-- The usb-storage file is taken over, it doesn't disappear
}, rem)
-- Collision resolved with early file remove in favor of new directory
-- Collision of file with new directory
local test_pkg = {
["package"] = {
["/etc/modules.d/usb-storage/other-file"] = true,
......@@ -482,6 +481,16 @@ function test_collisions()
["/etc/test-package"] = true
}
}
local col, erem, rem = B.collision_check(status, {}, test_pkg)
assert_table_equal({
["/etc/modules.d/usb-storage"] = {
["package"] = "new",
["kmod-usb-storage"] = "existing"
}
}, col)
assert_table_equal({}, erem)
assert_table_equal({}, rem)
-- Collision resolved with early file remove in favor of new directory
local col, erem, rem = B.collision_check(status, {['kmod-usb-storage'] = true}, test_pkg)
assert_table_equal({}, col)
assert_table_equal({
......@@ -493,13 +502,23 @@ function test_collisions()
["/lib/modules/3.18.21-70ea6b9a4b789c558ac9d579b5c1022f-10/usb-storage.ko"] = true,
["/etc/modules-boot.d/usb-storage"] = true,
}, rem)
-- Collision resolved with early directory remove in favor of new file
-- Collision of directory with new file
local test_pkg = {
["package"] = {
["/usr/share/terminfo"] = true,
["/etc/modules.d/usb-storage"] = true
}
}
local col, erem, rem = B.collision_check(status, {}, test_pkg)
assert_table_equal({
["/usr/share/terminfo"] = {
["package"] = "new",
["terminfo"] = "existing"
}
}, col)
assert_table_equal({}, erem)
assert_table_equal({}, rem)
-- Collision resolved with early directory remove in favor of new file
test_pkg.package["/etc/modules.d/usb-storage"] = true
local col, erem, rem = B.collision_check(status, {['terminfo'] = true}, test_pkg)
assert_table_equal({
["/etc/modules.d/usb-storage"] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment