aboutsummaryrefslogtreecommitdiff
path: root/spec/show_spec.lua
blob: cd34b5a57b8e2140f2af2b5ff98122ae11e11a7f (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
local test_env = require("spec.util.test_env")
local run = test_env.run
local testing_paths = test_env.testing_paths

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

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

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

   describe("basic tests with flags", function()
      it("invalid", function()
         assert.is_false(run.luarocks_bool("show invalid"))
      end)

      it("luacov", function()
         local output = run.luarocks("show luacov")
         assert.is.truthy(output:match("LuaCov"))
      end)

      it("luacov with uppercase name", function()
         local output = run.luarocks("show LuaCov")
         assert.is.truthy(output:match("LuaCov"))
      end)

      it("modules of luacov", function()
         local output = run.luarocks("show --modules luacov")
         assert.match("luacov.*luacov.defaults.*luacov.reporter.*luacov.reporter.default.*luacov.runner.*luacov.stats.*luacov.tick", output)
      end)

      it("--deps", function()
         assert(run.luarocks_bool("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
         local output = run.luarocks("show --deps has_namespaced_dep")
         assert.match("a_user/a_rock", output)
      end)

      it("list dependencies", function()
         assert(run.luarocks_bool("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
         local output = run.luarocks("show has_namespaced_dep")
         assert.match("a_user/a_rock.*2.0", output)
      end)

      it("rockspec of luacov", function()
         local output = run.luarocks("show --rockspec luacov")
         assert.is.truthy(output:match("luacov--0.15.0--1.rockspec"))
      end)

      it("mversion of luacov", function()
         local output = run.luarocks("show --mversion luacov")
         assert.is.truthy(output:match("0.15.0--1"))
      end)

      it("rock tree of luacov", function()
         local output = run.luarocks("show --rock-tree luacov")
      end)

      it("rock directory of luacov", function()
         local output = run.luarocks("show --rock-dir luacov")
      end)

      it("issues URL of luacov", function()
         local output = run.luarocks("show --issues luacov")
      end)

      it("labels of luacov", function()
         local output = run.luarocks("show --labels luacov")
      end)
   end)

   it("old version of luacov", function()
      run.luarocks("install luacov 0.15.0")
      run.luarocks_bool("show luacov 0.15.0")
   end)

   it("can find by substring", function()
      assert(run.luarocks_bool("install has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
      assert.match("a_build_dep", run.luarocks("show has_"))
   end)

   it("fails when substring matches multiple", function()
      assert(run.luarocks_bool("install has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
      assert(run.luarocks_bool("install a_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
      assert.match("multiple installed packages match the name 'dep'", run.luarocks("show dep"))
   end)

   it("shows #build_dependencies", function()
      assert(run.luarocks_bool("install has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
      assert.match("a_build_dep", run.luarocks("show has_build_dep"))
   end)

   it("gets #build_dependencies via --build-deps", function()
      assert(run.luarocks_bool("install has_build_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
      assert.match("a_build_dep", run.luarocks("show has_build_dep --build-deps"))
   end)

   it("shows #namespaces via --rock-namespace", function()
      assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
      assert.match("a_user", run.luarocks("show a_rock --rock-namespace"))
   end)

end)