Skip to content

Commit

Permalink
core: list return empty array instead of null, when no cores are inst…
Browse files Browse the repository at this point in the history
…alled (#2691)
  • Loading branch information
alessio-perugini authored Aug 13, 2024
1 parent a0d912d commit c5812ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit c5812ee

Please sign in to comment.