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.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua
index 008a91c8..0087159b 100644
--- a/spec/fetch_spec.lua
+++ b/spec/fetch_spec.lua
@@ -39,7 +39,8 @@ describe("luarocks fetch #unit #mock", function()
39 describe("fetch.fetch_url", function() 39 describe("fetch.fetch_url", function()
40 40
41 it("fetches the url argument and returns the absolute path of the fetched file", function() 41 it("fetches the url argument and returns the absolute path of the fetched file", function()
42 local fetchedfile = fetch.fetch_url("http://localhost:8080/file/a_rock.lua") 42 local fetchedfile, err = fetch.fetch_url("http://localhost:8080/file/a_rock.lua")
43 assert(fetchedfile, err)
43 assert.truthy(are_same_files(fetchedfile, lfs.currentdir() .. "/a_rock.lua")) 44 assert.truthy(are_same_files(fetchedfile, lfs.currentdir() .. "/a_rock.lua"))
44 local fd = assert(io.open(fetchedfile, "r")) 45 local fd = assert(io.open(fetchedfile, "r"))
45 local fetchedcontent = assert(fd:read("*a")) 46 local fetchedcontent = assert(fd:read("*a"))
@@ -109,6 +110,7 @@ describe("luarocks fetch #unit #mock", function()
109 110
110 it("returns true and fetches the url into a temporary dir", function() 111 it("returns true and fetches the url into a temporary dir", function()
111 local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test") 112 local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test")
113 assert(fetchedfile, tmpdir)
112 assert.truthy(are_same_files(fetchedfile, tmpdir .. "/a_rock.lua")) 114 assert.truthy(are_same_files(fetchedfile, tmpdir .. "/a_rock.lua"))
113 local fd = assert(io.open(fetchedfile, "r")) 115 local fd = assert(io.open(fetchedfile, "r"))
114 local fetchedcontent = assert(fd:read("*a")) 116 local fetchedcontent = assert(fd:read("*a"))
@@ -121,6 +123,7 @@ describe("luarocks fetch #unit #mock", function()
121 123
122 it("returns true and fetches the url into a temporary dir with custom filename", function() 124 it("returns true and fetches the url into a temporary dir with custom filename", function()
123 local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test", "my_a_rock.lua") 125 local fetchedfile, tmpdir = fetch.fetch_url_at_temp_dir("http://localhost:8080/file/a_rock.lua", "test", "my_a_rock.lua")
126 assert(fetchedfile, tmpdir)
124 assert.truthy(are_same_files(fetchedfile, tmpdir .. "/my_a_rock.lua")) 127 assert.truthy(are_same_files(fetchedfile, tmpdir .. "/my_a_rock.lua"))
125 assert.truthy(string.find(tmpdir, "test")) 128 assert.truthy(string.find(tmpdir, "test"))
126 local fd = assert(io.open(fetchedfile, "r")) 129 local fd = assert(io.open(fetchedfile, "r"))