From f7eb8df5363430a2b5ac288da5710ff382c632fe Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 3 Jun 2019 15:59:02 -0300 Subject: Tests: add a couple of tests for dir.normalize --- spec/dir_spec.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/spec/dir_spec.lua b/spec/dir_spec.lua index 08fb6e23..249f8aba 100644 --- a/spec/dir_spec.lua +++ b/spec/dir_spec.lua @@ -31,12 +31,23 @@ describe("Luarocks dir test #unit", function() 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")) + it("deduces the base dir from archives", 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")) + end) + it("returns the basename when not given an archive", function() + 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) + + describe("dir.normalize", function() + it("converts backslashes and removes trailing slashes", function() + assert.are.same("/foo/ovo", dir.normalize("\\foo\\ovo\\")) + assert.are.same("http://example.com/foo/ovo", dir.normalize("http://example.com/foo\\ovo\\")) + end) end) end) -- cgit v1.2.3-55-g6feb