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.lua33
1 files changed, 23 insertions, 10 deletions
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua
index 59f73b57..5f518e4d 100644
--- a/spec/fetch_spec.lua
+++ b/spec/fetch_spec.lua
@@ -1,4 +1,5 @@
1local test_env = require("spec.util.test_env") 1local test_env = require("spec.util.test_env")
2local git_repo = require("spec.util.git_repo")
2 3
3test_env.unload_luarocks() 4test_env.unload_luarocks()
4local fetch = require("luarocks.fetch") 5local fetch = require("luarocks.fetch")
@@ -6,23 +7,35 @@ local vers = require("luarocks.vers")
6 7
7describe("Luarocks fetch test #whitebox #w_fetch", function() 8describe("Luarocks fetch test #whitebox #w_fetch", function()
8 it("Fetch url to base dir", function() 9 it("Fetch url to base dir", function()
9 assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) 10 assert.are.same("v0.3", fetch.url_to_base_dir("https://example.com/hishamhm/lua-compat-5.2/archive/v0.3.zip"))
10 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) 11 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://example.com/hishamhm/lua-compat-5.2.zip"))
11 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) 12 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://example.com/hishamhm/lua-compat-5.2.tar.gz"))
12 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) 13 assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://example.com/hishamhm/lua-compat-5.2.tar.bz2"))
13 assert.are.same("parser.moon", fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) 14 assert.are.same("parser.moon", fetch.url_to_base_dir("git://example.com/Cirru/parser.moon"))
14 assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) 15 assert.are.same("v0.3", fetch.url_to_base_dir("https://example.com/hishamhm/lua-compat-5.2/archive/v0.3"))
15 end) 16 end)
16 17
17 describe("fetch_sources", function() 18 describe("fetch_sources #unix #git", function()
18 it("from Git", function() 19 local git
20
21 setup(function()
22 git = git_repo.start()
23 end)
24
25 teardown(function()
26 if git then
27 git:stop()
28 end
29 end)
30
31 it("from #git", function()
19 local rockspec = { 32 local rockspec = {
20 format_is_at_least = vers.format_is_at_least, 33 format_is_at_least = vers.format_is_at_least,
21 name = "testrock", 34 name = "testrock",
22 version = "dev-1", 35 version = "dev-1",
23 source = { 36 source = {
24 protocol = "git", 37 protocol = "git",
25 url = "git://github.com/luarocks/testrock", 38 url = "git://localhost:20000/testrock",
26 }, 39 },
27 variables = { 40 variables = {
28 GIT = "git", 41 GIT = "git",
@@ -31,7 +44,7 @@ describe("Luarocks fetch test #whitebox #w_fetch", function()
31 local pathname, tmpdir = fetch.fetch_sources(rockspec, false) 44 local pathname, tmpdir = fetch.fetch_sources(rockspec, false)
32 assert.are.same("testrock", pathname) 45 assert.are.same("testrock", pathname)
33 assert.match("luarocks_testrock%-dev%-1%-", tmpdir) 46 assert.match("luarocks_testrock%-dev%-1%-", tmpdir)
34 assert.match("^%d%d%d%d%d%d%d%d.%d%d%d%d%d%d.%x+$", rockspec.source.identifier) 47 assert.match("^%d%d%d%d%d%d%d%d.%d%d%d%d%d%d.%x+$", tostring(rockspec.source.identifier))
35 end) 48 end)
36 end) 49 end)
37 50