From 6399e79fa9d92df2d9c1fd643e85ed1e90d01379 Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 21 Jun 2023 12:33:04 +0200 Subject: [PATCH 1/2] Set `Platform.Intalled` to the installed release --- commands/core/search.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/core/search.go b/commands/core/search.go index 1d9a39c440a..69b81e3b369 100644 --- a/commands/core/search.go +++ b/commands/core/search.go @@ -85,6 +85,9 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse out := make([]*rpc.Platform, len(res)) for i, platformRelease := range res { out[i] = commands.PlatformReleaseToRPC(platformRelease) + if platformRelease.IsInstalled() { + out[i].Installed = platformRelease.Version.String() + } } // Sort result alphabetically and put deprecated platforms at the bottom sort.Slice( From 641f64ec85aa86bf2142fb961f52fb12ee2fe29f Mon Sep 17 00:00:00 2001 From: MatteoPologruto Date: Wed, 21 Jun 2023 12:35:26 +0200 Subject: [PATCH 2/2] Test that the json output contains `installed` --- internal/integrationtest/core/core_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/integrationtest/core/core_test.go b/internal/integrationtest/core/core_test.go index b2b68dd366e..d979603a3e0 100644 --- a/internal/integrationtest/core/core_test.go +++ b/internal/integrationtest/core/core_test.go @@ -68,9 +68,13 @@ func TestCoreSearch(t *testing.T) { require.NoError(t, err) require.Greater(t, len(strings.Split(string(out), "\n")), 2) + _, _, err = cli.Run("core", "install", "arduino:avr@1.8.6") + require.NoError(t, err) 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"}]`) // additional URL out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String())