Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 401fc9b

Browse files
committedDec 5, 2022
Migrate TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook from test_lib.py to lib_test.go
1 parent f12c34c commit 401fc9b

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed
 

‎internal/integrationtest/lib/lib_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -1266,3 +1266,37 @@ func TestInstallGitInvalidLibrary(t *testing.T) {
12661266
require.Contains(t, string(stderr), "library not valid")
12671267
require.NoDirExists(t, libInstallDir.String())
12681268
}
1269+
1270+
func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T) {
1271+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
1272+
defer env.CleanUp()
1273+
1274+
testPlatformName := "platform_with_bundled_library"
1275+
platformInstallDir := cli.SketchbookDir().Join("hardware", "arduino-beta-dev", testPlatformName)
1276+
require.NoError(t, platformInstallDir.Parent().MkdirAll())
1277+
1278+
// Install platform in Sketchbook hardware dir
1279+
wd, err := paths.Getwd()
1280+
require.NoError(t, err)
1281+
require.NoError(t, wd.Parent().Join("testdata", testPlatformName).CopyDirTo(platformInstallDir))
1282+
1283+
_, _, err = cli.Run("update")
1284+
require.NoError(t, err)
1285+
1286+
// Install latest version of library identical to one
1287+
// bundled with test platform
1288+
_, _, err = cli.Run("lib", "install", "USBHost")
1289+
require.NoError(t, err)
1290+
1291+
stdout, _, err := cli.Run("lib", "list", "--all", "--format", "json")
1292+
require.NoError(t, err)
1293+
requirejson.Len(t, stdout, 2)
1294+
// Verify both libraries have the same name
1295+
requirejson.Query(t, stdout, ".[0] | .library | .name", "\"USBHost\"")
1296+
requirejson.Query(t, stdout, ".[1] | .library | .name", "\"USBHost\"")
1297+
1298+
stdout, _, err = cli.Run("lib", "upgrade")
1299+
require.NoError(t, err)
1300+
// Empty output means nothing has been updated as expected
1301+
require.Empty(t, stdout)
1302+
}

‎test/test_lib.py

-32
Original file line numberDiff line numberDiff line change
@@ -206,38 +206,6 @@ def test_install_with_zip_path_multiple_libraries(run_command, downloads_dir, da
206206
assert ble_install_dir.exists()
207207

208208

209-
def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries_in_sketchbook(run_command, data_dir):
210-
test_platform_name = "platform_with_bundled_library"
211-
platform_install_dir = Path(data_dir, "hardware", "arduino-beta-dev", test_platform_name)
212-
platform_install_dir.mkdir(parents=True)
213-
214-
# Install platform in Sketchbook hardware dir
215-
shutil.copytree(
216-
Path(__file__).parent / "testdata" / test_platform_name,
217-
platform_install_dir,
218-
dirs_exist_ok=True,
219-
)
220-
221-
assert run_command(["update"])
222-
223-
# Install latest version of library identical to one
224-
# bundled with test platform
225-
assert run_command(["lib", "install", "USBHost"])
226-
227-
res = run_command(["lib", "list", "--all", "--format", "json"])
228-
assert res.ok
229-
libs = json.loads(res.stdout)
230-
assert len(libs) == 2
231-
# Verify both libraries have the same name
232-
assert libs[0]["library"]["name"] == "USBHost"
233-
assert libs[1]["library"]["name"] == "USBHost"
234-
235-
res = run_command(["lib", "upgrade"])
236-
assert res.ok
237-
# Empty output means nothing has been updated as expected
238-
assert res.stdout == ""
239-
240-
241209
def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries(run_command, data_dir):
242210
test_platform_name = "platform_with_bundled_library"
243211
platform_install_dir = Path(data_dir, "packages", "arduino", "hardware", "arch", "4.2.0")

0 commit comments

Comments
 (0)
Please sign in to comment.