|
18 | 18 | package packagemanager_test
|
19 | 19 |
|
20 | 20 | import (
|
| 21 | + "fmt" |
21 | 22 | "net/url"
|
22 | 23 | "testing"
|
23 | 24 |
|
@@ -295,3 +296,23 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
|
295 | 296 | }
|
296 | 297 | require.Equal(t, bossac18.InstallDir.String(), uploadProperties.Get("runtime.tools.bossac.path"))
|
297 | 298 | }
|
| 299 | + |
| 300 | +func TestIdentifyBoard(t *testing.T) { |
| 301 | + pm := packagemanager.NewPackageManager(customHardware, customHardware, customHardware, customHardware) |
| 302 | + pm.LoadHardwareFromDirectory(customHardware) |
| 303 | + |
| 304 | + identify := func(vid, pid string) []*cores.Board { |
| 305 | + return pm.IdentifyBoard(properties.NewFromHashmap(map[string]string{ |
| 306 | + "vid": vid, "pid": pid, |
| 307 | + })) |
| 308 | + } |
| 309 | + require.Equal(t, "[arduino:avr:uno]", fmt.Sprintf("%v", identify("0x2341", "0x0001"))) |
| 310 | + |
| 311 | + // Check indexed vid/pid format (vid.0/pid.0) |
| 312 | + require.Equal(t, "[test:avr:a]", fmt.Sprintf("%v", identify("0x9999", "0x0001"))) |
| 313 | + require.Equal(t, "[test:avr:b]", fmt.Sprintf("%v", identify("0x9999", "0x0002"))) |
| 314 | + require.Equal(t, "[test:avr:c]", fmt.Sprintf("%v", identify("0x9999", "0x0003"))) |
| 315 | + require.Equal(t, "[test:avr:c]", fmt.Sprintf("%v", identify("0x9999", "0x0004"))) |
| 316 | + // https://github.com/arduino/arduino-cli/issues/456 |
| 317 | + require.Equal(t, "[test:avr:d]", fmt.Sprintf("%v", identify("0x9999", "0x0005"))) |
| 318 | +} |
0 commit comments