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
5 changes: 5 additions & 0 deletions indexes/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ import (
// DownloadTool downloads and returns the path on the local filesystem of a tool
func DownloadTool(toolRelease *cores.ToolRelease) (*paths.Path, error) {
resource := toolRelease.GetCompatibleFlavour()
if resource == nil {
err := fmt.Errorf("tool %s not available for this OS", toolRelease.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err := fmt.Errorf("tool %s not available for this OS", toolRelease.String())
err := fmt.Errorf("tool %s not available for this OS/ARCH", toolRelease.String())

logrus.Error(err)
return nil, err
}
installDir := globals.FwUploaderPath.Join(
"tools",
toolRelease.Tool.Name,
Expand Down
22 changes: 22 additions & 0 deletions indexes/download/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,25 @@ func TestDownloadFirmware(t *testing.T) {
require.NotEmpty(t, firmwarePath)
require.FileExists(t, firmwarePath.String())
}

func TestDownloadToolMissingFlavour(t *testing.T) {
toolRelease := &cores.ToolRelease{
Version: semver.ParseRelaxed("1.7.0-arduino3"),
Tool: &cores.Tool{
Name: "bossac",
Package: &cores.Package{
Name: "arduino",
},
},
Flavors: []*cores.Flavor{},
}
defer os.RemoveAll(globals.FwUploaderPath.String())
indexFile := paths.New("testdata/package_index.json")
t.Logf("testing with index: %s", indexFile)
index, e := packageindex.LoadIndexNoSign(indexFile)
require.NoError(t, e)
require.NotEmpty(t, index)
toolDir, err := DownloadTool(toolRelease)
require.Error(t, err)
require.Empty(t, toolDir)
}