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