Skip to content

Commit 033a2dd

Browse files
Migrate TestInstallWithGitUrlRelativePath from test_lib.py to lib_test.go
1 parent bcdb302 commit 033a2dd

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

internal/integrationtest/lib/lib_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,3 +897,33 @@ func TestInstallWithGitLocalUrl(t *testing.T) {
897897
// Verifies library is installed
898898
require.DirExists(t, libInstallDir.String())
899899
}
900+
901+
func TestInstallWithGitUrlRelativePath(t *testing.T) {
902+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
903+
defer env.CleanUp()
904+
905+
_, _, err := cli.Run("update")
906+
require.NoError(t, err)
907+
908+
envVar := cli.GetDefaultEnv()
909+
envVar["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL"] = "true"
910+
911+
libInstallDir := cli.SketchbookDir().Join("libraries", "WiFi101")
912+
// Verifies library is not installed
913+
require.NoDirExists(t, libInstallDir.String())
914+
915+
// Clone repository locally
916+
gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
917+
repoDir := cli.SketchbookDir().Join("WiFi101")
918+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
919+
URL: gitUrl,
920+
})
921+
require.NoError(t, err)
922+
923+
cli.SetWorkingDir(cli.SketchbookDir())
924+
_, _, err = cli.RunWithCustomEnv(envVar, "lib", "install", "--git-url", "./WiFi101")
925+
require.NoError(t, err)
926+
927+
// Verifies library is installed
928+
require.DirExists(t, libInstallDir.String())
929+
}

test/test_lib.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -176,31 +176,6 @@ def test_install_with_git_url_local_file_uri(run_command, downloads_dir, data_di
176176
assert lib_install_dir.exists()
177177

178178

179-
def test_install_with_git_url_relative_path(run_command, downloads_dir, data_dir):
180-
assert run_command(["update"])
181-
182-
env = {
183-
"ARDUINO_DATA_DIR": data_dir,
184-
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
185-
"ARDUINO_SKETCHBOOK_DIR": data_dir,
186-
"ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL": "true",
187-
}
188-
189-
lib_install_dir = Path(data_dir, "libraries", "WiFi101")
190-
# Verifies library is not installed
191-
assert not lib_install_dir.exists()
192-
193-
# Clone repository locally
194-
git_url = "https://github.com/arduino-libraries/WiFi101.git"
195-
repo_dir = Path(data_dir, "WiFi101")
196-
assert Repo.clone_from(git_url, repo_dir)
197-
198-
assert run_command(["lib", "install", "--git-url", "./WiFi101"], custom_working_dir=data_dir, custom_env=env)
199-
200-
# Verifies library is installed
201-
assert lib_install_dir.exists()
202-
203-
204179
def test_install_with_git_url_does_not_create_git_repo(run_command, downloads_dir, data_dir):
205180
assert run_command(["update"])
206181

0 commit comments

Comments
 (0)