@@ -123,14 +123,21 @@ func NewArduinoCliWithinEnvironment(env *Environment, config *ArduinoCLIConfig)
123123// It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests.
124124// The Environment must be disposed by calling the CleanUp method via defer.
125125func CreateEnvForDaemon (t * testing.T ) (* Environment , * ArduinoCLI ) {
126+ return CreateEnvForDaemonWithUserAgent (t , "cli-test/0.0.0" )
127+ }
128+
129+ // CreateEnvForDaemonWithUserAgent performs the minimum required operations to start the arduino-cli daemon.
130+ // It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests.
131+ // The Environment must be disposed by calling the CleanUp method via defer.
132+ func CreateEnvForDaemonWithUserAgent (t * testing.T , userAgent string ) (* Environment , * ArduinoCLI ) {
126133 env := NewEnvironment (t )
127134
128135 cli := NewArduinoCliWithinEnvironment (env , & ArduinoCLIConfig {
129136 ArduinoCLIPath : FindRepositoryRootPath (t ).Join ("arduino-cli" ),
130137 UseSharedStagingFolder : true ,
131138 })
132139
133- _ = cli .StartDaemon (false )
140+ _ = cli .StartDaemon (false , userAgent )
134141 return env , cli
135142}
136143
@@ -410,7 +417,7 @@ func (cli *ArduinoCLI) run(stdoutBuff, stderrBuff io.Writer, stdinBuff io.Reader
410417}
411418
412419// StartDaemon starts the Arduino CLI daemon. It returns the address of the daemon.
413- func (cli * ArduinoCLI ) StartDaemon (verbose bool ) string {
420+ func (cli * ArduinoCLI ) StartDaemon (verbose bool , userAgent string ) string {
414421 args := []string {"daemon" , "--json" }
415422 if cli .cliConfigPath != nil {
416423 args = append ([]string {"--config-file" , cli .cliConfigPath .String ()}, args ... )
@@ -450,7 +457,11 @@ func (cli *ArduinoCLI) StartDaemon(verbose bool) string {
450457 for retries := 5 ; retries > 0 ; retries -- {
451458 time .Sleep (time .Second )
452459
453- conn , err := grpc .NewClient (cli .daemonAddr , grpc .WithTransportCredentials (insecure .NewCredentials ()))
460+ conn , err := grpc .NewClient (
461+ cli .daemonAddr ,
462+ grpc .WithTransportCredentials (insecure .NewCredentials ()),
463+ grpc .WithUserAgent (userAgent ),
464+ )
454465 if err != nil {
455466 connErr = err
456467 continue
0 commit comments