From 82de269830f7077c7ecaa7ce540b90699dca8e05 Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Tue, 13 Aug 2024 07:14:10 +0200 Subject: [PATCH] core: list return empty array instead of null, when no cores are installed --- internal/cli/core/list.go | 6 +++--- internal/integrationtest/core/core_test.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/cli/core/list.go b/internal/cli/core/list.go index 24bae8a82ab..4fe1661b0e5 100644 --- a/internal/cli/core/list.go +++ b/internal/cli/core/list.go @@ -88,9 +88,9 @@ func GetList(ctx context.Context, srv rpc.ArduinoCoreServiceServer, inst *rpc.In } func newCoreListResult(in []*rpc.PlatformSummary, updatableOnly bool) *coreListResult { - res := &coreListResult{updatableOnly: updatableOnly} - for _, platformSummary := range in { - res.Platforms = append(res.Platforms, result.NewPlatformSummary(platformSummary)) + res := &coreListResult{updatableOnly: updatableOnly, Platforms: make([]*result.PlatformSummary, len(in))} + for i, platformSummary := range in { + res.Platforms[i] = result.NewPlatformSummary(platformSummary) } return res } diff --git a/internal/integrationtest/core/core_test.go b/internal/integrationtest/core/core_test.go index 1f8850f0856..08ed34fadfd 100644 --- a/internal/integrationtest/core/core_test.go +++ b/internal/integrationtest/core/core_test.go @@ -1174,6 +1174,7 @@ func TestCoreListWhenNoPlatformAreInstalled(t *testing.T) { stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `0`) + requirejson.Query(t, stdout, `.platforms | select(.!=null)`, `[]`) stdout, _, err = cli.Run("core", "list") require.NoError(t, err) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy