Skip to content

Commit c3bf0fd

Browse files
Migrate TestInstallWithGitUrl from test_lib.py to lib_test.go
1 parent 9da3c17 commit c3bf0fd

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

internal/integrationtest/lib/lib_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,35 @@ func TestInstallNoDeps(t *testing.T) {
510510
require.NoError(t, err)
511511
requirejson.Query(t, stdout, ".[] | .library | .name", "\"MD_Parola\"")
512512
}
513+
514+
func TestInstallWithGitUrl(t *testing.T) {
515+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
516+
defer env.CleanUp()
517+
518+
// Initialize configs to enable --git-url flag
519+
envVar := cli.GetDefaultEnv()
520+
envVar["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL"] = "true"
521+
_, _, err := cli.RunWithCustomEnv(envVar, "config", "init", "--dest-dir", ".")
522+
require.NoError(t, err)
523+
524+
libInstallDir := cli.SketchbookDir().Join("libraries", "WiFi101")
525+
// Verifies library is not already installed
526+
require.NoDirExists(t, libInstallDir.String())
527+
528+
gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
529+
530+
// Test git-url library install
531+
stdout, _, err := cli.Run("lib", "install", "--git-url", gitUrl)
532+
require.NoError(t, err)
533+
require.Contains(t, string(stdout), "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk.")
534+
535+
// Verifies library is installed in expected path
536+
require.DirExists(t, libInstallDir.String())
537+
538+
// Reinstall library
539+
_, _, err = cli.Run("lib", "install", "--git-url", gitUrl)
540+
require.NoError(t, err)
541+
542+
// Verifies library remains installed
543+
require.DirExists(t, libInstallDir.String())
544+
}

test/test_lib.py

-31
Original file line numberDiff line numberDiff line change
@@ -96,37 +96,6 @@ def test_install_git_url_and_zip_path_flags_visibility(run_command, data_dir, do
9696
assert "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." in res.stdout
9797

9898

99-
def test_install_with_git_url(run_command, data_dir, downloads_dir):
100-
# Initialize configs to enable --git-url flag
101-
env = {
102-
"ARDUINO_DATA_DIR": data_dir,
103-
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
104-
"ARDUINO_SKETCHBOOK_DIR": data_dir,
105-
"ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL": "true",
106-
}
107-
assert run_command(["config", "init", "--dest-dir", "."], custom_env=env)
108-
109-
lib_install_dir = Path(data_dir, "libraries", "WiFi101")
110-
# Verifies library is not already installed
111-
assert not lib_install_dir.exists()
112-
113-
git_url = "https://github.com/arduino-libraries/WiFi101.git"
114-
115-
# Test git-url library install
116-
res = run_command(["lib", "install", "--git-url", git_url])
117-
assert res.ok
118-
assert "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." in res.stdout
119-
120-
# Verifies library is installed in expected path
121-
assert lib_install_dir.exists()
122-
123-
# Reinstall library
124-
assert run_command(["lib", "install", "--git-url", git_url])
125-
126-
# Verifies library remains installed
127-
assert lib_install_dir.exists()
128-
129-
13099
def test_install_with_git_url_fragment_as_branch(run_command, data_dir, downloads_dir):
131100
# Initialize configs to enable --git-url flag
132101
env = {

0 commit comments

Comments
 (0)