aboutsummaryrefslogtreecommitdiff
path: root/spec/dir_spec.lua
blob: 27966777916200a7d448fabdf748d45cf8266bc9 (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
local test_env = require("spec.util.test_env")

test_env.unload_luarocks()
test_env.setup_specs()
local dir = require("luarocks.dir")

describe("Luarocks dir test #unit", function()
   
   describe("dir.is_basic_protocol", function()
      it("checks whether the arguments represent a valid protocol and returns the result of the check", function()
         assert.truthy(dir.is_basic_protocol("http"))
         assert.truthy(dir.is_basic_protocol("https"))
         assert.truthy(dir.is_basic_protocol("ftp"))
         assert.truthy(dir.is_basic_protocol("file"))
         assert.falsy(dir.is_basic_protocol("git"))
         assert.falsy(dir.is_basic_protocol("git+https"))
         assert.falsy(dir.is_basic_protocol("invalid"))
      end)
   end)

   describe("dir.deduce_base_dir", function()
      assert.are.same("v0.3", dir.deduce_base_dir("https://example.com/hishamhm/lua-compat-5.2/archive/v0.3.zip"))
      assert.are.same("lua-compat-5.2", dir.deduce_base_dir("https://example.com/hishamhm/lua-compat-5.2.zip"))
      assert.are.same("lua-compat-5.2", dir.deduce_base_dir("https://example.com/hishamhm/lua-compat-5.2.tar.gz"))
      assert.are.same("lua-compat-5.2", dir.deduce_base_dir("https://example.com/hishamhm/lua-compat-5.2.tar.bz2"))
      assert.are.same("parser.moon", dir.deduce_base_dir("git://example.com/Cirru/parser.moon"))
      assert.are.same("v0.3", dir.deduce_base_dir("https://example.com/hishamhm/lua-compat-5.2/archive/v0.3"))
   end)

end)