Skip to content

Commit f2d57d5

Browse files
Migrate TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries from test_lib.py to lib_test.go
1 parent c3fa5e9 commit f2d57d5

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

Diff for: internal/integrationtest/lib/lib_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -1298,3 +1298,37 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T
12981298
// Empty output means nothing has been updated as expected
12991299
require.Empty(t, stdout)
13001300
}
1301+
1302+
func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) {
1303+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
1304+
defer env.CleanUp()
1305+
1306+
testPlatformName := "platform_with_bundled_library"
1307+
platformInstallDir := cli.DataDir().Join("packages", "arduino", "hardware", "arch", "4.2.0")
1308+
require.NoError(t, platformInstallDir.Parent().MkdirAll())
1309+
1310+
// Install platform in Sketchbook hardware dir
1311+
wd, err := paths.Getwd()
1312+
require.NoError(t, err)
1313+
require.NoError(t, wd.Parent().Join("testdata", testPlatformName).CopyDirTo(platformInstallDir))
1314+
1315+
_, _, err = cli.Run("update")
1316+
require.NoError(t, err)
1317+
1318+
// Install latest version of library identical to one
1319+
// bundled with test platform
1320+
_, _, err = cli.Run("lib", "install", "USBHost")
1321+
require.NoError(t, err)
1322+
1323+
stdout, _, err := cli.Run("lib", "list", "--all", "--format", "json")
1324+
require.NoError(t, err)
1325+
requirejson.Len(t, stdout, 2)
1326+
// Verify both libraries have the same name
1327+
requirejson.Query(t, stdout, ".[0] | .library | .name", "\"USBHost\"")
1328+
requirejson.Query(t, stdout, ".[1] | .library | .name", "\"USBHost\"")
1329+
1330+
stdout, _, err = cli.Run("lib", "upgrade")
1331+
require.NoError(t, err)
1332+
// Empty output means nothing has been updated as expected
1333+
require.Empty(t, stdout)
1334+
}

Diff for: test/test_lib.py

-32
Original file line numberDiff line numberDiff line change
@@ -204,35 +204,3 @@ def test_install_with_zip_path_multiple_libraries(run_command, downloads_dir, da
204204
# Verifies library are installed
205205
assert wifi_install_dir.exists()
206206
assert ble_install_dir.exists()
207-
208-
209-
def test_upgrade_does_not_try_to_upgrade_bundled_core_libraries(run_command, data_dir):
210-
test_platform_name = "platform_with_bundled_library"
211-
platform_install_dir = Path(data_dir, "packages", "arduino", "hardware", "arch", "4.2.0")
212-
platform_install_dir.mkdir(parents=True)
213-
214-
# Simulate installation of a platform with arduino-cli
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 == ""

0 commit comments

Comments
 (0)