@@ -339,3 +339,66 @@ func TestPackageManagerClear(t *testing.T) {
339
339
// Verifies both PackageManagers are now equal
340
340
require .Equal (t , & packageManager , & emptyPackageManager )
341
341
}
342
+
343
+ func TestFindToolsRequiredFromPlatformRelease (t * testing.T ) {
344
+ // Create all the necessary data to load discoveries
345
+ fakePath := paths .New ("fake-path" )
346
+
347
+ pm := packagemanager .NewPackageManager (fakePath , fakePath , fakePath , fakePath )
348
+ pack := pm .Packages .GetOrCreatePackage ("arduino" )
349
+ // some tool
350
+ tool := pack .GetOrCreateTool ("some-tool" )
351
+ toolRelease := tool .GetOrCreateRelease (semver .ParseRelaxed ("4.2.0" ))
352
+ // We set this to fake the tool is installed
353
+ toolRelease .InstallDir = fakePath
354
+ // some tool
355
+ tool = pack .GetOrCreateTool ("some-tool" )
356
+ toolRelease = tool .GetOrCreateRelease (semver .ParseRelaxed ("5.6.7" ))
357
+ // We set this to fake the tool is installed
358
+ toolRelease .InstallDir = fakePath
359
+ // some other tool
360
+ tool = pack .GetOrCreateTool ("some-other-tool" )
361
+ toolRelease = tool .GetOrCreateRelease (semver .ParseRelaxed ("6.6.6" ))
362
+ // We set this to fake the tool is installed
363
+ toolRelease .InstallDir = fakePath
364
+ // ble-discovery tool
365
+ tool = pack .GetOrCreateTool ("ble-discovery" )
366
+ toolRelease = tool .GetOrCreateRelease (semver .ParseRelaxed ("1.0.0" ))
367
+ // We set this to fake the tool is installed
368
+ toolRelease .InstallDir = fakePath
369
+ tool .GetOrCreateRelease (semver .ParseRelaxed ("0.1.0" ))
370
+
371
+ // serial-discovery tool
372
+ tool = pack .GetOrCreateTool ("serial-discovery" )
373
+ tool .GetOrCreateRelease (semver .ParseRelaxed ("1.0.0" ))
374
+ toolRelease = tool .GetOrCreateRelease (semver .ParseRelaxed ("0.1.0" ))
375
+ // We set this to fake the tool is installed
376
+ toolRelease .InstallDir = fakePath
377
+
378
+ platform := pack .GetOrCreatePlatform ("avr" )
379
+ release := platform .GetOrCreateRelease (semver .MustParse ("1.0.0" ))
380
+ release .ToolDependencies = append (release .ToolDependencies , & cores.ToolDependency {
381
+ ToolName : "some-tool" ,
382
+ ToolVersion : semver .ParseRelaxed ("4.2.0" ),
383
+ ToolPackager : "arduino" ,
384
+ })
385
+ release .ToolDependencies = append (release .ToolDependencies , & cores.ToolDependency {
386
+ ToolName : "some-other-tool" ,
387
+ ToolVersion : semver .ParseRelaxed ("6.6.6" ),
388
+ ToolPackager : "arduino" ,
389
+ })
390
+ release .DiscoveryDependencies = append (release .DiscoveryDependencies , & cores.DiscoveryDependency {
391
+ Name : "ble-discovery" ,
392
+ Packager : "arduino" ,
393
+ })
394
+ release .DiscoveryDependencies = append (release .DiscoveryDependencies , & cores.DiscoveryDependency {
395
+ Name : "serial-discovery" ,
396
+ Packager : "arduino" ,
397
+ })
398
+ // We set this to fake the platform is installed
399
+ release .InstallDir = fakePath
400
+
401
+ tools , err := pm .FindToolsRequiredFromPlatformRelease (release )
402
+ require .NoError (t , err )
403
+ require .Len (t , tools , 4 )
404
+ }
0 commit comments