@@ -13,6 +13,7 @@ import (
13
13
"github.com/tidepool-org/platform/auth/client"
14
14
"github.com/tidepool-org/platform/auth/service/service"
15
15
"github.com/tidepool-org/platform/auth/store"
16
+ storetest "github.com/tidepool-org/platform/auth/store/test"
16
17
platformclient "github.com/tidepool-org/platform/client"
17
18
"github.com/tidepool-org/platform/devicetokens"
18
19
logtest "github.com/tidepool-org/platform/log/test"
@@ -46,14 +47,14 @@ var _ = Describe("Client", func() {
46
47
name := "test auth client"
47
48
logger := logtest .NewLogger ()
48
49
if authStore == nil {
50
+ repo := storetest .NewDeviceTokenRepository ()
51
+ repo .Tokens = map [string ][]* devicetokens.DeviceToken {
52
+ testUserID : {
53
+ testDeviceToken1 ,
54
+ }}
55
+
49
56
authStore = & mockAuthStore {
50
- DeviceTokenRepository : & mockDeviceTokenRepository {
51
- Tokens : map [string ][]* devicetokens.DeviceToken {
52
- testUserID : {
53
- testDeviceToken1 ,
54
- },
55
- },
56
- },
57
+ DeviceTokenRepository : repo ,
57
58
}
58
59
}
59
60
providerFactory := & mockProviderFactory {}
@@ -80,10 +81,10 @@ var _ = Describe("Client", func() {
80
81
ctx := context .Background ()
81
82
server := NewServer ()
82
83
defer server .Close ()
84
+ repo := storetest .NewDeviceTokenRepository ()
85
+ repo .Error = fmt .Errorf ("test error" )
83
86
authStore := & mockAuthStore {
84
- DeviceTokenRepository : & mockDeviceTokenRepository {
85
- Error : fmt .Errorf ("test error" ),
86
- },
87
+ DeviceTokenRepository : repo ,
87
88
}
88
89
serviceClient := newTestServiceClient (server .URL (), authStore )
89
90
@@ -115,37 +116,3 @@ type mockProviderFactory struct{}
115
116
func (f * mockProviderFactory ) Get (typ string , name string ) (provider.Provider , error ) {
116
117
return nil , nil
117
118
}
118
-
119
- type mockDeviceTokenRepository struct {
120
- Error error
121
- Tokens map [string ][]* devicetokens.DeviceToken
122
- }
123
-
124
- func (r * mockDeviceTokenRepository ) GetAllByUserID (ctx context.Context , userID string ) ([]* devicetokens.Document , error ) {
125
- if r .Error != nil {
126
- return nil , r .Error
127
- }
128
-
129
- if tokens , ok := r .Tokens [userID ]; ok {
130
- docs := make ([]* devicetokens.Document , 0 , len (tokens ))
131
- for _ , token := range tokens {
132
- docs = append (docs , & devicetokens.Document {DeviceToken : * token })
133
- }
134
- return docs , nil
135
- }
136
- return nil , nil
137
- }
138
-
139
- func (r * mockDeviceTokenRepository ) Upsert (ctx context.Context , doc * devicetokens.Document ) error {
140
- if r .Error != nil {
141
- return r .Error
142
- }
143
- return nil
144
- }
145
-
146
- func (r * mockDeviceTokenRepository ) EnsureIndexes () error {
147
- if r .Error != nil {
148
- return r .Error
149
- }
150
- return nil
151
- }
0 commit comments