From b162729c9b6dcbb798409d1ebfa7da930c49ee04 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 2 Jan 2018 15:46:46 -0200 Subject: Tests: fetching from git stores an identifier --- spec/fetch_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'spec') diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 05a709e4..ab2cd54e 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua @@ -2,6 +2,7 @@ local test_env = require("test/test_environment") test_env.unload_luarocks() local fetch = require("luarocks.fetch") +local vers = require("luarocks.vers") describe("Luarocks fetch test #whitebox #w_fetch", function() it("Fetch url to base dir", function() @@ -12,4 +13,26 @@ describe("Luarocks fetch test #whitebox #w_fetch", function() assert.are.same("parser.moon", fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) end) + + describe("fetch_sources", function() + it("from Git", function() + local rockspec = { + format_is_at_least = vers.format_is_at_least, + name = "testrock", + version = "dev-1", + source = { + protocol = "git", + url = "git://github.com/luarocks/testrock", + }, + variables = { + GIT = "git", + }, + } + local pathname, tmpdir = fetch.fetch_sources(rockspec, false) + assert.are.same("testrock", pathname) + assert.match("luarocks_testrock%-dev%-1%-", tmpdir) + assert.match("^%d%d%d%d%d%d%d%d.%d%d%d%d%d%d.%x+$", rockspec.source.identifier) + end) + end) + end) -- cgit v1.2.3-55-g6feb