1616package monitor_test
1717
1818import (
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