@@ -2,7 +2,6 @@ package api_test
2
2
3
3
import (
4
4
"context"
5
- "io"
6
5
"net"
7
6
"testing"
8
7
"time"
@@ -17,6 +16,7 @@ import (
17
16
"google.golang.org/grpc/codes"
18
17
"google.golang.org/grpc/status"
19
18
"google.golang.org/grpc/test/bufconn"
19
+ "google.golang.org/protobuf/types/known/timestamppb"
20
20
)
21
21
22
22
const bufSize = 1024 * 1024
@@ -36,7 +36,11 @@ func TestGetDeviceConfiguration(t *testing.T) {
36
36
accessGroups := []string {"auth" }
37
37
38
38
db := & database.MockAPIServer {}
39
- db .On ("ReadSessionInfo" , mock .Anything , mock .Anything ).Return (& pb.Session {Groups : accessGroups }, nil )
39
+ db .On ("ReadSessionInfo" , mock .Anything , mock .Anything ).Return (
40
+ & pb.Session {
41
+ Groups : accessGroups ,
42
+ Expiry : timestamppb .New (time .Now ().Add (10 * time .Second )),
43
+ }, nil )
40
44
db .On ("ReadDeviceById" , mock .Anything , mock .Anything ).Return (& pb.Device {
41
45
Healthy : true ,
42
46
}, nil )
@@ -74,23 +78,7 @@ func TestGetDeviceConfiguration(t *testing.T) {
74
78
configClient , err := client .GetDeviceConfiguration (ctx , & pb.GetDeviceConfigurationRequest {})
75
79
assert .NoError (t , err )
76
80
77
- var resp * pb.GetDeviceConfigurationResponse
78
- for attempt := 0 ; attempt < 10 ; attempt ++ {
79
- resp , err = configClient .Recv ()
80
- if err == nil {
81
- break
82
- }
83
-
84
- if err == io .EOF {
85
- time .Sleep (100 * time .Millisecond )
86
- continue
87
- } else {
88
- t .Fatalf ("get device config: got unexpected err: %v" , err )
89
- }
90
- }
91
- if err != nil {
92
- t .Fatalf ("could not get device config in 10 attempts, last was err: %v" , err )
93
- }
81
+ resp , err := configClient .Recv ()
94
82
assert .NoError (t , err )
95
83
96
84
gw := resp .Gateways [0 ]
0 commit comments