File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ import (
4545// DownloadTool downloads and returns the path on the local filesystem of a tool
4646func DownloadTool (toolRelease * cores.ToolRelease ) (* paths.Path , error ) {
4747 resource := toolRelease .GetCompatibleFlavour ()
48+ if resource == nil {
49+ err := fmt .Errorf ("tool %s not available for this OS" , toolRelease .String ())
50+ logrus .Error (err )
51+ return nil , err
52+ }
4853 installDir := globals .FwUploaderPath .Join (
4954 "tools" ,
5055 toolRelease .Tool .Name ,
Original file line number Diff line number Diff line change @@ -140,3 +140,25 @@ func TestDownloadFirmware(t *testing.T) {
140140 require .NotEmpty (t , firmwarePath )
141141 require .FileExists (t , firmwarePath .String ())
142142}
143+
144+ func TestDownloadToolMissingFlavour (t * testing.T ) {
145+ toolRelease := & cores.ToolRelease {
146+ Version : semver .ParseRelaxed ("1.7.0-arduino3" ),
147+ Tool : & cores.Tool {
148+ Name : "bossac" ,
149+ Package : & cores.Package {
150+ Name : "arduino" ,
151+ },
152+ },
153+ Flavors : []* cores.Flavor {},
154+ }
155+ defer os .RemoveAll (globals .FwUploaderPath .String ())
156+ indexFile := paths .New ("testdata/package_index.json" )
157+ t .Logf ("testing with index: %s" , indexFile )
158+ index , e := packageindex .LoadIndexNoSign (indexFile )
159+ require .NoError (t , e )
160+ require .NotEmpty (t , index )
161+ toolDir , err := DownloadTool (toolRelease )
162+ require .Error (t , err )
163+ require .Empty (t , toolDir )
164+ }
You can’t perform that action at this time.
0 commit comments