Skip to content

Commit c5a062a

Browse files
Migrate TestInstallWithGitUrlFragmentAsBranch from test_lib.py to lib_test.go
1 parent c5e168e commit c5a062a

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

internal/integrationtest/lib/lib_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,36 @@ func TestInstallWithGitUrl(t *testing.T) {
622622
// Verifies library remains installed
623623
require.DirExists(t, libInstallDir.String())
624624
}
625+
626+
func TestInstallWithGitUrlFragmentAsBranch(t *testing.T) {
627+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
628+
defer env.CleanUp()
629+
630+
// Initialize configs to enable --git-url flag
631+
envVar := cli.GetDefaultEnv()
632+
envVar["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL"] = "true"
633+
_, _, err := cli.RunWithCustomEnv(envVar, "config", "init", "--dest-dir", ".")
634+
require.NoError(t, err)
635+
636+
libInstallDir := cli.SketchbookDir().Join("libraries", "WiFi101")
637+
// Verifies library is not already installed
638+
require.NoDirExists(t, libInstallDir.String())
639+
640+
gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
641+
642+
// Test that a bad ref fails
643+
_, _, err = cli.Run("lib", "install", "--git-url", gitUrl+"#x-ref-does-not-exist")
644+
require.Error(t, err)
645+
646+
// Verifies library is installed in expected path
647+
_, _, err = cli.Run("lib", "install", "--git-url", gitUrl+"#0.16.0")
648+
require.NoError(t, err)
649+
require.DirExists(t, libInstallDir.String())
650+
651+
// Reinstall library at an existing ref
652+
_, _, err = cli.Run("lib", "install", "--git-url", gitUrl+"#master")
653+
require.NoError(t, err)
654+
655+
// Verifies library remains installed
656+
require.DirExists(t, libInstallDir.String())
657+
}

test/test_lib.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -96,39 +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_fragment_as_branch(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 that a bad ref fails
116-
res = run_command(["lib", "install", "--git-url", git_url + "#x-ref-does-not-exist"])
117-
assert res.failed
118-
119-
# Verifies library is installed in expected path
120-
res = run_command(["lib", "install", "--git-url", git_url + "#0.16.0"])
121-
assert res.ok
122-
assert lib_install_dir.exists()
123-
124-
# Reinstall library at an existing ref
125-
assert run_command(["lib", "install", "--git-url", git_url + "#master"])
126-
assert res.ok
127-
128-
# Verifies library remains installed
129-
assert lib_install_dir.exists()
130-
131-
13299
def test_install_with_zip_path(run_command, data_dir, downloads_dir):
133100
# Initialize configs to enable --zip-path flag
134101
env = {

0 commit comments

Comments
 (0)