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
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(
......
......@@ -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())
......
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