From 1191c7effe45e77db437fd8d1faa843fb88640cc Mon Sep 17 00:00:00 2001 From: Erich L Foster Date: Sat, 27 Apr 2024 18:22:31 +0200 Subject: [PATCH] Fix test --- tests/devcontainer_cli/folder_utils_spec.lua | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/devcontainer_cli/folder_utils_spec.lua b/tests/devcontainer_cli/folder_utils_spec.lua index 745711e..552ed24 100644 --- a/tests/devcontainer_cli/folder_utils_spec.lua +++ b/tests/devcontainer_cli/folder_utils_spec.lua @@ -1,4 +1,4 @@ -local folder_utils = require("devcontainer_cli.folder_utils") +local folder_utils = require("devcontainer-cli.folder_utils") describe("In folder_utils functions", function() it( @@ -8,18 +8,26 @@ describe("In folder_utils functions", function() -- This test assumes that we are in the root folder of the project local project_root_folder = vim.fn.getcwd() -- We change the current directory to a subfolder - vim.fn.chdir("lua/devcontainer_cli") + vim.fn.chdir("lua/devcontainer-cli") local devcontainer_cli_folder = vim.fn.getcwd() -- First we check that the we properly changed the directory - assert(devcontainer_cli_folder == project_root_folder .. "/lua/devcontainer_cli") - -- In such subfolder the function for getting the root_folder is called - local root_folder = folder_utils.get_root() + assert(devcontainer_cli_folder == project_root_folder .. "/lua/devcontainer-cli") + -- Verify that the project root is at the current level when toplevel is false + local root_folder = folder_utils.get_root(false) -- From the subfolder, we check that the get_root function returns the folder where the git repo is located instead of the CWD - print("ROOT" .. root_folder) - print("PROJECT_ROOT" .. project_root_folder) + print("ROOT: " .. root_folder) + print("PROJECT_ROOT: " .. project_root_folder) assert(root_folder == project_root_folder) -- After running the test we come back to the initial location vim.fn.chdir(project_root_folder) + + -- Verify that the project root is at HOME (location of top most devcontainer directory) when toplevel is true + project_root = os.getenv("HOME") + root_folder = folder_utils.get_root(false) + -- From the subfolder, we check that the get_root function returns the folder where the git repo is located instead of the CWD + print("ROOT: " .. root_folder) + print("PROJECT_ROOT: " .. project_root) + assert(root_folder == project_root_folder) end ) end)