forked from Silverfish/proton-bridge
Fixing unit tests for client manager.
* [x] pmapi: refresh auth uid won't change
* [x] bridge tests:
* update mocks
* delete auth when FinishLogin fails
* check for mailbox password
* add `gomock.InOrder` for better test control
* [x] fix linter issues except TODOs
* [x] make rootScheme unexported
* [x] store tests: update mocks
This commit is contained in:
@ -180,9 +180,10 @@ func hasAPIAuth(accountName string) error {
|
||||
if err != nil {
|
||||
return internalError(err, "getting user %s", account.Username())
|
||||
}
|
||||
a.Eventually(ctx.GetTestingT(), func() bool {
|
||||
return bridgeUser.HasAPIAuth()
|
||||
}, 5*time.Second, 10*time.Millisecond)
|
||||
a.Eventually(ctx.GetTestingT(),
|
||||
bridgeUser.HasAPIAuth,
|
||||
5*time.Second, 10*time.Millisecond,
|
||||
)
|
||||
return ctx.GetTestingError()
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,6 @@ import (
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/internal/preferences"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
)
|
||||
|
||||
// GetBridge returns bridge instance.
|
||||
@ -60,7 +59,7 @@ func newBridgeInstance(
|
||||
cfg *fakeConfig,
|
||||
credStore bridge.CredentialsStorer,
|
||||
eventListener listener.Listener,
|
||||
clientManager *pmapi.ClientManager,
|
||||
clientManager bridge.ClientManager,
|
||||
) *bridge.Bridge {
|
||||
version := os.Getenv("VERSION")
|
||||
bridge.UpdateCurrentUserAgent(version, runtime.GOOS, "", "")
|
||||
|
||||
@ -148,7 +148,9 @@ func (api *FakePMAPI) AuthRefresh(token string) (*pmapi.Auth, error) {
|
||||
}
|
||||
|
||||
func (api *FakePMAPI) Logout() {
|
||||
api.DeleteAuth()
|
||||
if err := api.DeleteAuth(); err != nil {
|
||||
api.log.WithError(err).Error("delete auth failed during logout")
|
||||
}
|
||||
api.ClearData()
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ func (ctl *Controller) TurnInternetConnectionOn() {
|
||||
}
|
||||
|
||||
type fakeTransport struct {
|
||||
ctl *Controller
|
||||
ctl *Controller
|
||||
transport http.RoundTripper
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user