aboutsummaryrefslogtreecommitdiff
path: root/spec/fetch_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/fetch_spec.lua')
-rw-r--r--spec/fetch_spec.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua
index 8194a298..008a91c8 100644
--- a/spec/fetch_spec.lua
+++ b/spec/fetch_spec.lua
@@ -52,8 +52,25 @@ describe("luarocks fetch #unit #mock", function()
52 end) 52 end)
53 53
54 it("returns the absolute path of the filename argument if the url represents a file", function() 54 it("returns the absolute path of the filename argument if the url represents a file", function()
55 local file = fetch.fetch_url("file://a_rock.lua") 55 test_env.run_in_tmp(function(tmpdir)
56 assert.truthy(are_same_files(file, lfs.currentdir() .. "/a_rock.lua")) 56 write_file("test.lua", "return {}", finally)
57
58 fs.change_dir(tmpdir)
59 local file, err = fetch.fetch_url("file://test.lua")
60 assert.truthy(file, err)
61 assert.truthy(are_same_files(file, lfs.currentdir() .. "/test.lua"))
62 fs.pop_dir()
63 end, finally)
64 end)
65
66 it("fails if local path is invalid and returns a helpful hint for relative paths", function()
67 test_env.run_in_tmp(function(tmpdir)
68 write_file("test.lua", "return {}", finally)
69
70 local ok, err = fetch.fetch_url("file://boo.lua")
71 assert.falsy(ok)
72 assert.match("note that given path in rockspec is not absolute: file://boo.lua", err)
73 end, finally)
57 end) 74 end)
58 75
59 it("returns false and does nothing if the url argument contains a nonexistent file", function() 76 it("returns false and does nothing if the url argument contains a nonexistent file", function()