Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c5812ee

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

File tree

2 files changed

+4
-3
lines changed
Filter options

2 files changed

+4
-3
lines changed

‎internal/cli/core/list.go

Copy file name to clipboardExpand all lines: internal/cli/core/list.go
+3-3Lines 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

Copy file name to clipboardExpand all lines: internal/integrationtest/core/core_test.go
+1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.