summaryrefslogtreecommitdiff
path: root/spec/download_spec.lua
blob: 42f7200850948e1e2473285ac6d88a04d2f46f78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local test_env = require("spec.util.test_env")
local lfs = require("lfs")
local run = test_env.run
local testing_paths = test_env.testing_paths

test_env.unload_luarocks()

local extra_rocks = {
   "/validate-args-1.5.4-1.rockspec"
}

describe("luarocks download #integration", function()

   before_each(function()
      test_env.setup_specs(extra_rocks)
   end)

   it("with no flags/arguments", function()
      assert.is_false(run.luarocks_bool("download"))
   end)

   it("invalid", function()
      assert.is_false(run.luarocks_bool("download invalid"))
   end)

   it("all with delete downloaded files", function() --TODO maybe download --all more rocks
      assert.is_true(run.luarocks_bool("download --all validate-args"))
      assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec"))
      test_env.remove_files(lfs.currentdir(), "validate--args--")
   end)
   
   it("rockspec version", function()
      assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1"))
      assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec"))
      test_env.remove_files(lfs.currentdir(), "validate--args--")
   end)

   describe("#namespaces", function()
      it("retrieves namespaced rockspec", function()
         finally(function()
            os.remove("a_rock-2.0-1.rockspec")
         end)
         assert(run.luarocks_bool("download a_user/a_rock --rockspec --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
         assert(lfs.attributes("a_rock-2.0-1.rockspec"))
      end)

      it("retrieves namespaced rock", function()
         finally(function()
            os.remove("a_rock-2.0-1.src.rock")
         end)
         assert(run.luarocks_bool("download a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
         assert(lfs.attributes("a_rock-2.0-1.src.rock"))
      end)
   end)


end)