Skip to content

Commit c5e168e

Browse files
Migrate TestInstallWithGitUrl from test_lib.py to lib_test.go
1 parent 1562879 commit c5e168e

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

internal/integrationtest/lib/lib_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,35 @@ func TestInstallNoDeps(t *testing.T) {
590590
require.NoError(t, err)
591591
requirejson.Query(t, stdout, ".[] | .library | .name", "\"MD_Parola\"")
592592
}
593+
594+
func TestInstallWithGitUrl(t *testing.T) {
595+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
596+
defer env.CleanUp()
597+
598+
// Initialize configs to enable --git-url flag
599+
envVar := cli.GetDefaultEnv()
600+
envVar["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL"] = "true"
601+
_, _, err := cli.RunWithCustomEnv(envVar, "config", "init", "--dest-dir", ".")
602+
require.NoError(t, err)
603+
604+
libInstallDir := cli.SketchbookDir().Join("libraries", "WiFi101")
605+
// Verifies library is not already installed
606+
require.NoDirExists(t, libInstallDir.String())
607+
608+
gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
609+
610+
// Test git-url library install
611+
stdout, _, err := cli.Run("lib", "install", "--git-url", gitUrl)
612+
require.NoError(t, err)
613+
require.Contains(t, string(stdout), "--git-url and --zip-path flags allow installing untrusted files, use it at your own risk.")
614+
615+
// Verifies library is installed in expected path
616+
require.DirExists(t, libInstallDir.String())
617+
618+
// Reinstall library
619+
_, _, err = cli.Run("lib", "install", "--git-url", gitUrl)
620+
require.NoError(t, err)
621+
622+
// Verifies library remains installed
623+
require.DirExists(t, libInstallDir.String())
624+
}

test/test_lib.py

Lines changed: 0 additions & 31 deletions
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)