@@ -123,14 +123,21 @@ func NewArduinoCliWithinEnvironment(env *Environment, config *ArduinoCLIConfig)
123
123
// It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests.
124
124
// The Environment must be disposed by calling the CleanUp method via defer.
125
125
func 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 ) {
126
133
env := NewEnvironment (t )
127
134
128
135
cli := NewArduinoCliWithinEnvironment (env , & ArduinoCLIConfig {
129
136
ArduinoCLIPath : FindRepositoryRootPath (t ).Join ("arduino-cli" ),
130
137
UseSharedStagingFolder : true ,
131
138
})
132
139
133
- _ = cli .StartDaemon (false )
140
+ _ = cli .StartDaemon (false , userAgent )
134
141
return env , cli
135
142
}
136
143
@@ -410,7 +417,7 @@ func (cli *ArduinoCLI) run(stdoutBuff, stderrBuff io.Writer, stdinBuff io.Reader
410
417
}
411
418
412
419
// 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 {
414
421
args := []string {"daemon" , "--json" }
415
422
if cli .cliConfigPath != nil {
416
423
args = append ([]string {"--config-file" , cli .cliConfigPath .String ()}, args ... )
@@ -450,7 +457,11 @@ func (cli *ArduinoCLI) StartDaemon(verbose bool) string {
450
457
for retries := 5 ; retries > 0 ; retries -- {
451
458
time .Sleep (time .Second )
452
459
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
+ )
454
465
if err != nil {
455
466
connErr = err
456
467
continue
0 commit comments