|
18 | 18 | package packagemanager_test
|
19 | 19 |
|
20 | 20 | import (
|
| 21 | + "fmt" |
21 | 22 | "net/url"
|
22 | 23 | "testing"
|
23 | 24 |
|
@@ -170,3 +171,23 @@ func TestFindToolsRequiredForBoard(t *testing.T) {
|
170 | 171 | }
|
171 | 172 | require.Equal(t, bossac18.InstallDir.String(), uploadProperties.Get("runtime.tools.bossac.path"))
|
172 | 173 | }
|
| 174 | + |
| 175 | +func TestIdentifyBoard(t *testing.T) { |
| 176 | + pm := packagemanager.NewPackageManager(customHardware, customHardware, customHardware, customHardware) |
| 177 | + pm.LoadHardwareFromDirectory(customHardware) |
| 178 | + |
| 179 | + identify := func(vid, pid string) []*cores.Board { |
| 180 | + return pm.IdentifyBoard(properties.NewFromHashmap(map[string]string{ |
| 181 | + "vid": vid, "pid": pid, |
| 182 | + })) |
| 183 | + } |
| 184 | + require.Equal(t, "[arduino:avr:uno]", fmt.Sprintf("%v", identify("0x2341", "0x0001"))) |
| 185 | + |
| 186 | + // Check indexed vid/pid format (vid.0/pid.0) |
| 187 | + require.Equal(t, "[test:avr:a]", fmt.Sprintf("%v", identify("0x9999", "0x0001"))) |
| 188 | + require.Equal(t, "[test:avr:b]", fmt.Sprintf("%v", identify("0x9999", "0x0002"))) |
| 189 | + require.Equal(t, "[test:avr:c]", fmt.Sprintf("%v", identify("0x9999", "0x0003"))) |
| 190 | + require.Equal(t, "[test:avr:c]", fmt.Sprintf("%v", identify("0x9999", "0x0004"))) |
| 191 | + // https://github.com/arduino/arduino-cli/issues/456 |
| 192 | + require.Equal(t, "[test:avr:d]", fmt.Sprintf("%v", identify("0x9999", "0x0005"))) |
| 193 | +} |
0 commit comments