Skip to content

Commit 8aed8e6

Browse files
committed
Added integration test
1 parent 8c0c78c commit 8aed8e6

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Diff for: internal/integrationtest/arduino-cli.go

+12
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,15 @@ func (inst *ArduinoCLIInstance) Upload(ctx context.Context, fqbn, sketchPath, po
694694
logCallf(">>> Upload(%v %v port/protocol=%s/%s)\n", fqbn, sketchPath, port, protocol)
695695
return uploadCl, err
696696
}
697+
698+
// BoardIdentify calls the "BoardIdentify" gRPC method.
699+
func (inst *ArduinoCLIInstance) BoardIdentify(ctx context.Context, props map[string]string, useCloudAPI bool) (*commands.BoardIdentifyResponse, error) {
700+
req := &commands.BoardIdentifyRequest{
701+
Instance: inst.instance,
702+
Properties: props,
703+
UseCloudApiForUnknownBoardDetection: useCloudAPI,
704+
}
705+
logCallf(">>> BoardIdentify(%+v)\n", req)
706+
resp, err := inst.cli.daemonClient.BoardIdentify(ctx, req)
707+
return resp, err
708+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

Comments
 (0)