Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate TestInstallWithGitUrlDoesNotCreateGitRepo from test_lib.py to…
… lib_test.go
  • Loading branch information
MatteoPologruto committed Dec 12, 2022
commit 2e8b1f7daa08761e5b409d6804afb8ea194c24f4
29 changes: 29 additions & 0 deletions internal/integrationtest/lib/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,3 +927,32 @@ func TestInstallWithGitUrlRelativePath(t *testing.T) {
// Verifies library is installed
require.DirExists(t, libInstallDir.String())
}

func TestInstallWithGitUrlDoesNotCreateGitRepo(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

_, _, err := cli.Run("update")
require.NoError(t, err)

envVar := cli.GetDefaultEnv()
envVar["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL"] = "true"

libInstallDir := cli.SketchbookDir().Join("libraries", "WiFi101")
// Verifies library is not installed
require.NoDirExists(t, libInstallDir.String())

// Clone repository locally
gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
repoDir := cli.SketchbookDir().Join("WiFi101")
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
URL: gitUrl,
})
require.NoError(t, err)

_, _, err = cli.RunWithCustomEnv(envVar, "lib", "install", "--git-url", repoDir.String())
require.NoError(t, err)

// Verifies installed library is not a git repository
require.NoDirExists(t, libInstallDir.Join(".git").String())
}
25 changes: 0 additions & 25 deletions test/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,31 +176,6 @@ def test_install_with_git_url_local_file_uri(run_command, downloads_dir, data_di
assert lib_install_dir.exists()


def test_install_with_git_url_does_not_create_git_repo(run_command, downloads_dir, data_dir):
assert run_command(["update"])

env = {
"ARDUINO_DATA_DIR": data_dir,
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
"ARDUINO_SKETCHBOOK_DIR": data_dir,
"ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL": "true",
}

lib_install_dir = Path(data_dir, "libraries", "WiFi101")
# Verifies library is not installed
assert not lib_install_dir.exists()

# Clone repository locally
git_url = "https://github.com/arduino-libraries/WiFi101.git"
repo_dir = Path(data_dir, "WiFi101")
assert Repo.clone_from(git_url, repo_dir)

assert run_command(["lib", "install", "--git-url", repo_dir], custom_env=env)

# Verifies installed library is not a git repository
assert not Path(lib_install_dir, ".git").exists()


def test_install_with_git_url_multiple_libraries(run_command, downloads_dir, data_dir):
assert run_command(["update"])

Expand Down