refactor: don't pass client directly to store syncer

This commit is contained in:
James Houlahan
2020-04-16 17:17:44 +02:00
parent 38f0425670
commit e95aece6d3
10 changed files with 71 additions and 76 deletions

View File

@ -94,7 +94,6 @@ func mockConnectedUser(m mocks) {
m.credentialsStore.EXPECT().Get("user").Return(testCredentials, nil),
m.pmapiClient.EXPECT().AuthRefresh("token").Return(testAuthRefresh, nil),
//TODO m.credentialsStore.EXPECT().UpdateToken("user", ":reftok").Return(nil),
m.pmapiClient.EXPECT().Unlock(testCredentials.MailboxPassword).Return(nil, nil),
m.pmapiClient.EXPECT().UnlockAddresses([]byte(testCredentials.MailboxPassword)).Return(nil),
@ -106,6 +105,20 @@ func mockConnectedUser(m mocks) {
)
}
// mockAuthUpdate simulates bridge calling UpdateAuthToken on the given user.
// This would normally be done by Bridge when it receives an auth from the ClientManager,
// but as we don't have a full bridge instance here, we do this manually.
func mockAuthUpdate(user *User, token string, m mocks) {
gomock.InOrder(
m.credentialsStore.EXPECT().UpdateToken("user", ":"+token).Return(nil),
m.credentialsStore.EXPECT().Get("user").Return(credentialsWithToken(token), nil),
)
user.updateAuthToken(refreshWithToken(token))
waitForEvents()
}
func TestNewBridgeWithConnectedUser(t *testing.T) {
m := initMocks(t)
defer m.ctrl.Finish()