|
| 1 | +// This file is part of arduino-cli. |
| 2 | +// |
| 3 | +// Copyright 2024 ARDUINO SA (http://www.arduino.cc/) |
| 4 | +// |
| 5 | +// This software is released under the GNU General Public License version 3, |
| 6 | +// which covers the main part of arduino-cli. |
| 7 | +// The terms of this license can be found at: |
| 8 | +// https://www.gnu.org/licenses/gpl-3.0.en.html |
| 9 | +// |
| 10 | +// You can be released from the requirements of the above licenses by purchasing |
| 11 | +// a commercial license. Buying such a license is mandatory if you want to |
| 12 | +// modify or otherwise use the software for commercial activities involving the |
| 13 | +// Arduino software without disclosing the source code of your own applications. |
| 14 | +// To purchase a commercial license, send an email to [email protected]. |
| 15 | + |
| 16 | +package daemon_test |
| 17 | + |
| 18 | +import ( |
| 19 | + "context" |
| 20 | + "errors" |
| 21 | + "fmt" |
| 22 | + "io" |
| 23 | + "testing" |
| 24 | + |
| 25 | + "github.com/arduino/arduino-cli/internal/integrationtest" |
| 26 | + "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" |
| 27 | + "github.com/stretchr/testify/require" |
| 28 | +) |
| 29 | + |
| 30 | +func TestBoardIdentification(t *testing.T) { |
| 31 | + env, cli := integrationtest.CreateEnvForDaemon(t) |
| 32 | + defer env.CleanUp() |
| 33 | + |
| 34 | + grpcInst := cli.Create() |
| 35 | + require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) { |
| 36 | + fmt.Printf("INIT> %v\n", ir.GetMessage()) |
| 37 | + })) |
| 38 | + |
| 39 | + plInst, err := grpcInst.PlatformInstall(context.Background(), "arduino", "avr", "1.8.6", true) |
| 40 | + require.NoError(t, err) |
| 41 | + for { |
| 42 | + msg, err := plInst.Recv() |
| 43 | + if errors.Is(err, io.EOF) { |
| 44 | + break |
| 45 | + } |
| 46 | + require.NoError(t, err) |
| 47 | + fmt.Printf("INSTALL> %v\n", msg) |
| 48 | + } |
| 49 | + |
| 50 | + resp, err := grpcInst.BoardIdentify(context.Background(), map[string]string{"vid": "0x2341", "pid": "0x0043"}, false) |
| 51 | + require.NoError(t, err) |
| 52 | + require.Len(t, resp.GetBoards(), 1) |
| 53 | + require.Equal(t, "arduino:avr:uno", resp.GetBoards()[0].GetFqbn()) |
| 54 | +} |
0 commit comments