1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00
CC-Tweaked/src/test/resources/test-rom/spec/programs/delete_spec.lua
hydraz 5b0ce7410d Make delete delete many files (#210)
Actually, many *globs*. It additionally prints the glob if no files
matched it, since that's clearer.

Also move the ComputerTestDelegate's filesystem to be disk-based. This
is what actual computers use, and the MemoryMount is a little broken.
2019-05-25 09:02:42 +01:00

36 lines
962 B
Lua

describe("The rm program", function()
local function touch(file)
io.open(file, "w"):close()
end
it("deletes one file", function()
touch("/test-files/a.txt")
shell.run("rm /test-files/a.txt")
expect(fs.exists("/test-files/a.txt")):eq(false)
end)
it("deletes many files", function()
touch("/test-files/a.txt")
touch("/test-files/b.txt")
touch("/test-files/c.txt")
shell.run("rm /test-files/a.txt /test-files/b.txt")
expect(fs.exists("/test-files/a.txt")):eq(false)
expect(fs.exists("/test-files/b.txt")):eq(false)
expect(fs.exists("/test-files/c.txt")):eq(true)
end)
it("deletes a glob", function()
touch("/test-files/a.txt")
touch("/test-files/b.txt")
shell.run("rm /test-files/*.txt")
expect(fs.exists("/test-files/a.txt")):eq(false)
expect(fs.exists("/test-files/b.txt")):eq(false)
end)
end)