Skip to content

Commit e603d2c

Browse files
committed
Added some more checks to gRPC integration tests
1 parent dd621ee commit e603d2c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

internal/integrationtest/arduino-cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func CreateEnvForDaemon(t *testing.T) (*Environment, *ArduinoCLI) {
131131
UseSharedStagingFolder: true,
132132
})
133133

134-
_ = cli.StartDaemon(false)
134+
require.Equal(t, "127.0.0.1:50051", cli.StartDaemon(false))
135135
return env, cli
136136
}
137137

internal/integrationtest/monitor/monitor_grpc_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package monitor_test
1717

1818
import (
19+
"bytes"
1920
"context"
2021
"errors"
2122
"fmt"
@@ -60,6 +61,7 @@ func TestMonitorGRPCClose(t *testing.T) {
6061
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
6162
mon, err := grpcInst.Monitor(ctx, ports[0].GetPort())
6263
var tmpFile *paths.Path
64+
fullRx := bytes.NewBuffer(nil)
6365
for {
6466
monResp, err := mon.Recv()
6567
if err != nil {
@@ -68,9 +70,11 @@ func TestMonitorGRPCClose(t *testing.T) {
6870
}
6971
fmt.Printf("MON> %v\n", monResp)
7072
if rx := monResp.GetRxData(); rx != nil {
71-
if matches := tmpFileMatcher.FindAllStringSubmatch(string(rx), -1); len(matches) > 0 {
73+
fullRx.Write(rx)
74+
if matches := tmpFileMatcher.FindAllStringSubmatch(fullRx.String(), -1); len(matches) > 0 {
7275
fmt.Println("Found tmpFile", matches[0][1])
7376
tmpFile = paths.New(matches[0][1])
77+
fullRx.Reset()
7478
}
7579
}
7680
}
@@ -87,6 +91,7 @@ func TestMonitorGRPCClose(t *testing.T) {
8791
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
8892
mon, err := grpcInst.Monitor(ctx, ports[0].GetPort())
8993
var tmpFile *paths.Path
94+
fullRx := bytes.NewBuffer(nil)
9095
for {
9196
monResp, err := mon.Recv()
9297
if errors.Is(err, io.EOF) {
@@ -97,13 +102,16 @@ func TestMonitorGRPCClose(t *testing.T) {
97102
require.NoError(t, err)
98103
fmt.Printf("MON> %v\n", monResp)
99104
if rx := monResp.GetRxData(); rx != nil {
100-
if matches := tmpFileMatcher.FindAllStringSubmatch(string(rx), -1); len(matches) > 0 {
105+
fullRx.Write(rx)
106+
if matches := tmpFileMatcher.FindAllStringSubmatch(fullRx.String(), -1); len(matches) > 0 {
101107
fmt.Println("Found tmpFile", matches[0][1])
102108
tmpFile = paths.New(matches[0][1])
109+
fullRx.Reset()
103110
go func() {
104111
time.Sleep(time.Second)
105112
fmt.Println("<MON Sent close command")
106-
mon.Send(&commands.MonitorRequest{Message: &commands.MonitorRequest_Close{Close: true}})
113+
err := mon.Send(&commands.MonitorRequest{Message: &commands.MonitorRequest_Close{Close: true}})
114+
require.NoError(t, err)
107115
}()
108116
}
109117
}

0 commit comments

Comments
 (0)