Skip to content

Commit eca9d9a

Browse files
Set installed property for installed platform when core search is executed (#2223)
* Set `Platform.Intalled` to the installed release * Test that the json output contains `installed`
1 parent 9bc2afc commit eca9d9a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: commands/core/search.go

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse
8585
out := make([]*rpc.Platform, len(res))
8686
for i, platformRelease := range res {
8787
out[i] = commands.PlatformReleaseToRPC(platformRelease)
88+
if platformRelease.IsInstalled() {
89+
out[i].Installed = platformRelease.Version.String()
90+
}
8891
}
8992
// Sort result alphabetically and put deprecated platforms at the bottom
9093
sort.Slice(

Diff for: internal/integrationtest/core/core_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ func TestCoreSearch(t *testing.T) {
6868
require.NoError(t, err)
6969
require.Greater(t, len(strings.Split(string(out), "\n")), 2)
7070

71+
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
72+
require.NoError(t, err)
7173
out, _, err = cli.Run("core", "search", "avr", "--format", "json")
7274
require.NoError(t, err)
7375
requirejson.NotEmpty(t, out)
76+
// Verify that "installed" is set
77+
requirejson.Contains(t, out, `[{installed: "1.8.6"}]`)
7478

7579
// additional URL
7680
out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String())

0 commit comments

Comments
 (0)