Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
core: list return empty array instead of null, when no cores are inst…
…alled
  • Loading branch information
alessio-perugini committed Aug 13, 2024
commit 82de269830f7077c7ecaa7ce540b90699dca8e05
6 changes: 3 additions & 3 deletions internal/cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading