# # # patch "tests/automate_inventory/__driver__.lua" # from [16722b9eb51dbd60bfd1add6ac5850724b478215] # to [7f56659e1bb4a4858d220e88823c5f833bd500c5] # ============================================================ --- tests/automate_inventory/__driver__.lua 16722b9eb51dbd60bfd1add6ac5850724b478215 +++ tests/automate_inventory/__driver__.lua 7f56659e1bb4a4858d220e88823c5f833bd500c5 @@ -473,8 +473,91 @@ old_type = "directory", fs_type = "none", status = {"dropped"}}) --- FIXME: tests for renaming directories +---------- +-- check for drop file / add dir with the same name and vice versa --- FIXME: add test for 'pivot_root' +addfile("still-a-file--soon-a-dir", "bla") +adddir("still-a-dir--soon-a-file") +commit() +check(mtn("drop", "still-a-file--soon-a-dir"), 0, false, false) +check(mtn("drop", "still-a-dir--soon-a-file"), 0, false, false) +adddir("still-a-file--soon-a-dir") +addfile("still-a-dir--soon-a-file", "bla") + +check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +parsed = parse_basic_io(readfile("stdout")) + +-- FIXME: The next two tests fail, mainly because the status "dropped" is +-- wrongly reported as "rename_source" +index = find_basic_io_line (parsed, {name = "path", values = "still-a-file--soon-a-dir"}) +check_inventory (parsed, index, +{ path = "still-a-file--soon-a-dir", +old_type = "file", +new_type = "directory", + fs_type = "directory", + status = {"dropped", "added", "known"}}) + +index = find_basic_io_line (parsed, {name = "path", values = "still-a-dir--soon-a-file"}) +check_inventory (parsed, index, +{ path = "still-a-dir--soon-a-file", +old_type = "directory", +new_type = "file", + fs_type = "file", + status = {"dropped", "added", "known"}}) + +---------- +-- check for attribute changes + +addfile("file-with-attributes", "bla") +check(mtn("attr", "set", "file-with-attributes", "foo", "bar"), 0, false, false) + +check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +parsed = parse_basic_io(readfile("stdout")) + +-- FIXME: This test fails as well, because the "changes" stanza is completly +-- omitted. While it was obvious in the old format that added files always had +-- a P(atch) and it seemed natural to just omit this information here, we now +-- also track attribute additions for files here which are not at all mandatory +-- for new files and therefor this is an information which actually _should not_ +-- be ommitted +index = find_basic_io_line (parsed, {name = "path", values = "file-with-attributes"}) +check_inventory (parsed, index, +{ path = "file-with-attributes", +new_type = "file", + fs_type = "file", + status = {"added", "known"}, +changes = {"content", "attributes"}}) + +commit() + +check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +parsed = parse_basic_io(readfile("stdout")) +index = find_basic_io_line (parsed, {name = "path", values = "file-with-attributes"}) +check_inventory (parsed, index, +{ path = "file-with-attributes", +old_type = "file", +new_type = "file", + fs_type = "file", + status = {"known"}}) + +check(mtn("attr", "drop", "file-with-attributes", "foo"), 0, false, false) + +check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +parsed = parse_basic_io(readfile("stdout")) +index = find_basic_io_line (parsed, {name = "path", values = "file-with-attributes"}) +check_inventory (parsed, index, +{ path = "file-with-attributes", +old_type = "file", +new_type = "file", + fs_type = "file", + status = {"known"}, + changes = {"attrs"}}) + +-- FIXME: tests for renaming directories +-- also test that iff foo/ is renamed to bar/, any previous foo/node is +-- now listed as bar/node + +-- FIXME: add test for 'pivot_root' + -- end of file