Unverified Commit c5812eea authored by Alessio Perugini's avatar Alessio Perugini Committed by GitHub

core: list return empty array instead of null, when no cores are installed (#2691)

parent a0d912da
...@@ -88,9 +88,9 @@ func GetList(ctx context.Context, srv rpc.ArduinoCoreServiceServer, inst *rpc.In ...@@ -88,9 +88,9 @@ func GetList(ctx context.Context, srv rpc.ArduinoCoreServiceServer, inst *rpc.In
} }
func newCoreListResult(in []*rpc.PlatformSummary, updatableOnly bool) *coreListResult { func newCoreListResult(in []*rpc.PlatformSummary, updatableOnly bool) *coreListResult {
res := &coreListResult{updatableOnly: updatableOnly} res := &coreListResult{updatableOnly: updatableOnly, Platforms: make([]*result.PlatformSummary, len(in))}
for _, platformSummary := range in { for i, platformSummary := range in {
res.Platforms = append(res.Platforms, result.NewPlatformSummary(platformSummary)) res.Platforms[i] = result.NewPlatformSummary(platformSummary)
} }
return res return res
} }
......
...@@ -1174,6 +1174,7 @@ func TestCoreListWhenNoPlatformAreInstalled(t *testing.T) { ...@@ -1174,6 +1174,7 @@ func TestCoreListWhenNoPlatformAreInstalled(t *testing.T) {
stdout, _, err := cli.Run("core", "list", "--json") stdout, _, err := cli.Run("core", "list", "--json")
require.NoError(t, err) require.NoError(t, err)
requirejson.Query(t, stdout, `.platforms | length`, `0`) requirejson.Query(t, stdout, `.platforms | length`, `0`)
requirejson.Query(t, stdout, `.platforms | select(.!=null)`, `[]`)
stdout, _, err = cli.Run("core", "list") stdout, _, err = cli.Run("core", "list")
require.NoError(t, err) require.NoError(t, err)
......
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