8000 [breaking] Updated gRPC Platform API by cmaglie · Pull Request #2357 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

[breaking] Updated gRPC Platform API #2357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Oct 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
28f1f71
Updated gRPC Pltform API, regenerated API
cmaglie Oct 6, 2023
86b171d
Adapted cores.Platform and PlatformRelease to the new gRPC API
cmaglie Oct 16, 2023
2031172
Fixed search_test.go
cmaglie Oct 16, 2023
28cc496
Removed gRPC PlatformList command
cmaglie Oct 16, 2023
24a1dd3
Other adaptation of platform structures
cmaglie Oct 16, 2023
9d2fd89
Adapt arguuments completion to use PlatformSearch instead of Platform…
cmaglie Oct 16, 2023
c80d0ff
Adapt 'core list' to use PlatformSearch instead of PlatformList
cmaglie Oct 16, 2023
175a6d2
Adapt 'core upgrade' command to use PlatformSearch instead of Platfor…
cmaglie Oct 16, 2023
3b41351
Adapted some integration tests
cmaglie Oct 16, 2023
3c7bc1a
Fix integreation test
cmaglie Oct 9, 2023
0a055a6
apply changes to search vidpid
alessio-perugini Oct 10, 2023
f11b45d
Better handling of 'core list' results
cmaglie Oct 10, 2023
abe05fa
Better handling of 'core search' results
cmaglie Oct 10, 2023
7f3a6cb
Better handling of 'core outdated' results
cmaglie Oct 10, 2023
aca91e6
add 'orderedmap' data structure
alessio-perugini Oct 10, 2023
b8ae4f3
Made orderedmap more generic
cmaglie Oct 11, 2023
8c98f74
fix regression on 'ParseReference'
alessio-perugini Oct 11, 2023
6a6897b
wip: fix 'core' integrationtests
alessio-perugini Oct 11, 2023
7ad2ca4
wip: fix 'core' sorting tests
alessio-perugini Oct 11, 2023
cccf397
fix regression which skipped mannually instaled core in core list
alessio-perugini Oct 12, 2023
8b8ce96
wip: add more 'core' integration tests
alessio-perugini Oct 12, 2023 8000
3cee33b
regression: all flag takes precedence above updatable in core list
alessio-perugini Oct 12, 2023
064f57f
lint: ignore unexported-return (revive)
alessio-perugini Oct 12, 2023
ea0854e
license: regenerate and add missin headers
alessio-perugini Oct 12, 2023
64a2631
tests: fix 'board' integrations
alessio-perugini Oct 12, 2023
d010385
fix: regression not showing manually installed platform in 'core list'
alessio-perugini Oct 12, 2023
1d4b9e2
wip: add test to orderedmap
alessio-perugini Oct 12, 2023
87ea190
add more orderdmap tests
alessio-perugini Oct 13, 2023
655a5af
orderdmap: add json tests
alessio-perugini Oct 13, 2023
5fd313c
update DOCS
alessio-perugini Oct 13, 2023
d9dd825
apply CR suggestions
alessio-perugini Oct 16, 2023
494e923
fix proto numeration
alessio-perugini Oct 19, 2023
8528612
docs: update to release 0.36.0
alessio-perugini Oct 19, 2023
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
wip: fix 'core' integrationtests
  • Loading branch information
alessio-perugini committed Oct 23, 2023
commit 6a6897b88a3489499dff7f677d234aaa8ed26579
64 changes: 40 additions & 24 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestCorrectHandlingOfPlatformVersionProperty(t *testing.T) {
// Trigger problematic call
out, _, err := cli.Run("core", "list", "--format", "json")
require.NoError(t, err)
requirejson.Contains(t, out, `[{"id":"DxCore-dev:megaavr","installed":"1.4.10","name":"DxCore"}]`)
requirejson.Contains(t, out, `[{"id":"DxCore-dev:megaavr","installed_version":"1.4.10","name":"DxCore"}]`)
}

func TestCoreSearch(t *testing.T) {
Expand All @@ -73,8 +73,8 @@ func TestCoreSearch(t *testing.T) {
out, _, err = cli.Run("core", "search", "avr", "--format", "json")
require.NoError(t, err)
requirejson.NotEmpty(t, out)
// Verify that "installed" is set
requirejson.Contains(t, out, `[{installed: "1.8.6"}]`)
// Verify that "installed_version" is set
requirejson.Contains(t, out, `[{installed_version: "1.8.6"}]`)

// additional URL
out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String())
Expand All @@ -84,10 +84,10 @@ func TestCoreSearch(t *testing.T) {
// show all versions
out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err)
requirejson.Len(t, out, 3)
requirejson.Query(t, out, `.[].releases | length`, "3")

checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) {
jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version)
jqquery := fmt.Sprintf(`[{id:"%s", releases:{"%s":{}}}]`, id, version)
requirejson.Contains(t, out, jqquery, "platform %s@%s is missing from the output", id, version)
}

Expand Down Expand Up @@ -171,7 +171,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
// same thing in JSON format, also check the number of platforms found is the same
stdout, _, err = cli.Run("core", "search", "--format", "json")
require.NoError(t, err)
requirejson.Contains(t, stdout, `[ { "name":"test_core" } ]`)
requirejson.Contains(t, stdout, `[{"id": "test:x86", "releases": { "2.0.0": {"name":"test_core"}}}]`)
requirejson.Query(t, stdout, "length", fmt.Sprint(numPlatforms))

// list all with additional urls, check the test core is there
Expand All @@ -188,8 +188,8 @@ func TestCoreSearchNoArgs(t *testing.T) {
// same thing in JSON format, also check the number of platforms found is the same
stdout, _, err = cli.Run("core", "search", "--format", "json", "--additional-urls="+url.String())
require.NoError(t, err)
requirejson.Contains(t, stdout, `[ { "name":"test_core" } ]`)
requirejson.Query(t, stdout, "length", fmt.Sprint(numPlatforms))
requirejson.Contains(t, stdout, `[{"id": "test:x86", "releases": { "3.0.0": {"name":"test_core"}}}]`)
requirejson.Query(t, stdout, `[.[].releases | length] | add`, fmt.Sprint(numPlatforms))
}

func TestCoreUpdateIndexUrlNotFound(t *testing.T) {
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestCoreInstall(t *testing.T) {
require.NoError(t, err)
stdout, _, err := cli.Run("core", "list", "--format", "json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.[] | select(.id == "arduino:avr") | .installed`, `"1.6.16"`)
requirejson.Query(t, stdout, `.[] | select(.id == "arduino:avr") | .installed_version`, `"1.6.16"`)

// Replace it with the same with --no-overwrite (should NOT fail)
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.16", "--no-overwrite")
Expand All @@ -318,22 +318,22 @@ func TestCoreInstall(t *testing.T) {
require.NoError(t, err)
stdout, _, err = cli.Run("core", "list", "--format", "json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.[] | select(.id == "arduino:avr") | .installed`, `"1.6.17"`)
requirejson.Query(t, stdout, `.[] | select(.id == "arduino:avr") | .installed_version`, `"1.6.17"`)

// Confirm core is listed as "updatable"
stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json")
require.NoError(t, err)
jsonout := requirejson.Parse(t, stdout)
q := jsonout.Query(`.[] | select(.id == "arduino:avr")`)
q.Query(".installed").MustEqual(`"1.6.17"`)
latest := q.Query(".latest")
q.Query(".installed_version").MustEqual(`"1.6.17"`)
latest := q.Query(".latest_version")

// Upgrade the core to latest version
_, _, err = cli.Run("core", "upgrade", "arduino:avr")
require.NoError(t, err)
stdout, _, err = cli.Run("core", "list", "--format", "json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.[] | select(.id == "arduino:avr") | .installed`, latest.String())
requirejson.Query(t, stdout, `.[] | select(.id == "arduino:avr") | .installed_version`, latest.String())

// double check the core isn't updatable anymore
stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json")
Expand Down Expand Up @@ -483,10 +483,14 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) {
requirejson.Contains(t, stdout, `[
{
"id": "arduino-beta-development:avr",
"latest": "1.8.3",
"name": "Arduino AVR Boards"
"latest_version": "1.8.3",
"releases": {
"1.8.3": {
"name": "Arduino AVR Boards"
}
}
]`)
}
]`)
}

func TestCoreListUpdatableAllFlags(t *testing.T) {
Expand Down Expand Up @@ -519,10 +523,14 @@ func TestCoreListUpdatableAllFlags(t *testing.T) {
requirejson.Contains(t, stdout, `[
{
"id": "arduino-beta-development:avr",
"latest": "1.8.3",
"name": "Arduino AVR Boards"
"latest_version": "1.8.3",
"releases": {
"1.8.3": {
"name": "Arduino AVR Boards"
}
}
]`)
}
]`)
}

func TestCoreUpgradeRemovesUnusedTools(t *testing.T) {
Expand Down Expand Up @@ -592,7 +600,11 @@ func TestCoreListWithInstalledJson(t *testing.T) {
requirejson.Contains(t, stdout, `[
{
"id": "adafruit:avr",
"name": "Adafruit AVR Boards"
"releases": {
"1.4.13": {
"name": "Adafruit AVR Boards"
}
}
}
]`)

Expand All @@ -614,7 +626,11 @@ func TestCoreListWithInstalledJson(t *testing.T) {
requirejson.Contains(t, stdout, `[
{
"id": "adafruit:avr",
"name": "Adafruit Boards"
"releases": {
"1.4.13": {
"name": "Adafruit Boards"
}
}
}
]`)
}
Expand Down Expand Up @@ -940,10 +956,10 @@ func TestCoreListOutdatedCore(t *testing.T) {
stdout, _, err := cli.Run("core", "list", "--format", "json")
require.NoError(t, err)
requirejson.Len(t, stdout, 1)
requirejson.Query(t, stdout, ".[0] | .installed", "\"1.8.6\"")
installedVersion, err := semver.Parse(strings.Trim(requirejson.Parse(t, stdout).Query(".[0] | .installed").String(), "\""))
requirejson.Query(t, stdout, ".[0] | .installed_version", "\"1.8.6\"")
installedVersion, err := semver.Parse(strings.Trim(requirejson.Parse(t, stdout).Query(".[0] | .installed_version").String(), "\""))
require.NoError(t, err)
latestVersion, err := semver.Parse(strings.Trim(requirejson.Parse(t, stdout).Query(".[0] | .latest").String(), "\""))
latestVersion, err := semver.Parse(strings.Trim(requirejson.Parse(t, stdout).Query(".[0] | .latest_version").String(), "\""))
require.NoError(t, err)
// Installed version must be older than latest
require.True(t, installedVersion.LessThan(latestVersion))
Expand Down
0