Skip to content

Commit

Permalink
When launching core list with no installed platforms print `no plat…
Browse files Browse the repository at this point in the history
…forms installed` (arduino#2238)
  • Loading branch information
alessio-perugini authored Jul 6, 2023
1 parent 0f516bb commit df12786
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ func (ir installedResult) Data() interface{} {
}

func (ir installedResult) String() string {
if ir.platforms == nil || len(ir.platforms) == 0 {
return ""
if len(ir.platforms) == 0 {
return tr("No platforms installed.")
}

t := table.New()
t.SetHeader(tr("ID"), tr("Installed"), tr("Latest"), tr("Name"))
for _, p := range ir.platforms {
Expand Down
13 changes: 13 additions & 0 deletions internal/integrationtest/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,3 +1058,16 @@ func TestCoreUpgradeWarningWithPackageInstalledButNotIndexed(t *testing.T) {
requirejson.Query(t, jsonStdout, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`)
})
}

func TestCoreListWhenNoPlatformAreInstalled(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

stdout, _, err := cli.Run("core", "list", "--format", "json")
require.NoError(t, err)
requirejson.Empty(t, stdout)

stdout, _, err = cli.Run("core", "list")
require.NoError(t, err)
require.Equal(t, "No platforms installed.\n", string(stdout))
}

0 comments on commit df12786

Please sign in to comment.