Skip to content

Commit c5812ee

Browse files
core: list return empty array instead of null, when no cores are installed (#2691)
1 parent a0d912d commit c5812ee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/cli/core/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func GetList(ctx context.Context, srv rpc.ArduinoCoreServiceServer, inst *rpc.In
8888
}
8989

9090
func newCoreListResult(in []*rpc.PlatformSummary, updatableOnly bool) *coreListResult {
91-
res := &coreListResult{updatableOnly: updatableOnly}
92-
for _, platformSummary := range in {
93-
res.Platforms = append(res.Platforms, result.NewPlatformSummary(platformSummary))
91+
res := &coreListResult{updatableOnly: updatableOnly, Platforms: make([]*result.PlatformSummary, len(in))}
92+
for i, platformSummary := range in {
93+
res.Platforms[i] = result.NewPlatformSummary(platformSummary)
9494
}
9595
return res
9696
}

internal/integrationtest/core/core_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,7 @@ func TestCoreListWhenNoPlatformAreInstalled(t *testing.T) {
11741174
stdout, _, err := cli.Run("core", "list", "--json")
11751175
require.NoError(t, err)
11761176
requirejson.Query(t, stdout, `.platforms | length`, `0`)
1177+
requirejson.Query(t, stdout, `.platforms | select(.!=null)`, `[]`)
11771178

11781179
stdout, _, err = cli.Run("core", "list")
11791180
require.NoError(t, err)

0 commit comments

Comments
 (0)
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