Unverified Commit eca9d9a8 authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

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`
parent 9bc2afcf
...@@ -85,6 +85,9 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse ...@@ -85,6 +85,9 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse
out := make([]*rpc.Platform, len(res)) out := make([]*rpc.Platform, len(res))
for i, platformRelease := range res { for i, platformRelease := range res {
out[i] = commands.PlatformReleaseToRPC(platformRelease) 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 result alphabetically and put deprecated platforms at the bottom
sort.Slice( sort.Slice(
......
...@@ -68,9 +68,13 @@ func TestCoreSearch(t *testing.T) { ...@@ -68,9 +68,13 @@ func TestCoreSearch(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Greater(t, len(strings.Split(string(out), "\n")), 2) 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") out, _, err = cli.Run("core", "search", "avr", "--format", "json")
require.NoError(t, err) require.NoError(t, err)
requirejson.NotEmpty(t, out) requirejson.NotEmpty(t, out)
// Verify that "installed" is set
requirejson.Contains(t, out, `[{installed: "1.8.6"}]`)
// additional URL // additional URL
out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String()) out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment