File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ import (
45
45
// DownloadTool downloads and returns the path on the local filesystem of a tool
46
46
func DownloadTool (toolRelease * cores.ToolRelease ) (* paths.Path , error ) {
47
47
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
+ }
48
53
installDir := globals .FwUploaderPath .Join (
49
54
"tools" ,
50
55
toolRelease .Tool .Name ,
Original file line number Diff line number Diff line change @@ -140,3 +140,25 @@ func TestDownloadFirmware(t *testing.T) {
140
140
require .NotEmpty (t , firmwarePath )
141
141
require .FileExists (t , firmwarePath .String ())
142
142
}
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