mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add unit tests for pkgmgr.install_dir
This commit is contained in:
parent
db612c10ee
commit
adc89f7977
2 changed files with 247 additions and 6 deletions
|
@ -244,11 +244,7 @@ end
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
function pkgmgr.is_valid_modname(modpath)
|
||||
if modpath:find("-") ~= nil then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
return modpath:match("[^a-z0-9_]") == nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -521,6 +517,8 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
|
|||
local basefolder = pkgmgr.get_base_folder(path)
|
||||
|
||||
if expected_type == "txp" then
|
||||
assert(basename)
|
||||
|
||||
-- There's no good way to detect a texture pack, so let's just assume
|
||||
-- it's correct for now.
|
||||
if basefolder and basefolder.type ~= "invalid" and basefolder.type ~= "txp" then
|
||||
|
@ -544,7 +542,7 @@ function pkgmgr.install_dir(expected_type, path, basename, targetpath)
|
|||
|
||||
-- Check type
|
||||
if basefolder.type ~= expected_type and (basefolder.type ~= "modpack" or expected_type ~= "mod") then
|
||||
return nil, fgettext("Unable to install a $1 as a $1", basefolder.type, expected_type)
|
||||
return nil, fgettext("Unable to install a $1 as a $2", basefolder.type, expected_type)
|
||||
end
|
||||
|
||||
-- Set targetpath if not predetermined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue