summaryrefslogtreecommitdiff
path: root/spec/util_spec.lua
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2025-02-03 21:29:42 +0100
committerMike Vink <mike@pionative.com>2025-02-03 21:29:42 +0100
commit5155816b7b925dec5d5feb1568b1d7ceb00938b9 (patch)
treedeca28ea15e79f6f804c3d90d2ba757881638af5 /spec/util_spec.lua
fetch tarballHEADmaster
Diffstat (limited to 'spec/util_spec.lua')
-rw-r--r--spec/util_spec.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/util_spec.lua b/spec/util_spec.lua
new file mode 100644
index 0000000..0f199c9
--- /dev/null
+++ b/spec/util_spec.lua
@@ -0,0 +1,55 @@
+local test_env = require("spec.util.test_env")
+local lfs = require("lfs")
+local run = test_env.run
+
+describe("Basic tests #integration", function()
+
+ before_each(function()
+ test_env.setup_specs()
+ end)
+
+ it("--version", function()
+ assert.is_true(run.luarocks_bool("--version"))
+ end)
+
+ it("unknown command", function()
+ assert.is_false(run.luarocks_bool("unknown_command"))
+ end)
+
+ it("arguments fail", function()
+ assert.is_false(run.luarocks_bool("--porcelain=invalid"))
+ assert.is_false(run.luarocks_bool("--invalid-flag"))
+ assert.is_false(run.luarocks_bool("--server"))
+ assert.is_false(run.luarocks_bool("--server --porcelain"))
+ assert.is_false(run.luarocks_bool("--invalid-flag=abc"))
+ assert.is_false(run.luarocks_bool("invalid=5"))
+ end)
+
+ it("executing from not existing directory #unix", function()
+ local main_path = lfs.currentdir()
+ assert.is_true(lfs.mkdir("idontexist"))
+ assert.is_true(lfs.chdir("idontexist"))
+ local delete_path = lfs.currentdir()
+ assert.is_true(os.remove(delete_path))
+
+ local output = run.luarocks("")
+ assert.is.falsy(output:find("the Lua package manager"))
+ assert.is_true(lfs.chdir(main_path))
+
+ output = run.luarocks("")
+ assert.is.truthy(output:find("the Lua package manager"))
+ end)
+
+ it("--timeout", function()
+ assert.is.truthy(run.luarocks("--timeout=10"))
+ end)
+
+ it("--timeout invalid", function()
+ assert.is_false(run.luarocks_bool("--timeout=abc"))
+ end)
+
+ it("--only-server", function()
+ assert.is.truthy(run.luarocks("--only-server=testing"))
+ end)
+
+end)