1
0

GODT-2160: Prevent double closing of bridge if restart fails

Set imapServer instance to nil once the server is no longer running to
prevent multiple calls to close on shutdown.
This commit is contained in:
Leander Beernaert
2022-11-29 08:38:21 +01:00
parent ae7ae2886f
commit 1c374b59d3
3 changed files with 48 additions and 2 deletions

View File

@ -442,6 +442,30 @@ func TestBridge_FactoryReset(t *testing.T) {
})
}
/* // This test will be enabled in a followup patch
func TestBridge_ChangeCacheDirectory(t *testing.T) {
withEnv(t, func(ctx context.Context, s *server.Server, netCtl *proton.NetCtl, locator bridge.Locator, vaultKey []byte) {
withBridge(ctx, t, s.GetHostURL(), netCtl, locator, vaultKey, func(bridge *bridge.Bridge, mocks *bridge.Mocks) {
newCacheDir := t.TempDir()
// Login the user.
userID, err := bridge.LoginFull(ctx, username, password, nil, nil)
require.NoError(t, err)
// The user is now connected.
require.Equal(t, []string{userID}, bridge.GetUserIDs())
require.Equal(t, []string{userID}, getConnectedUserIDs(t, bridge))
// Change directory
_ = bridge.SetGluonDir(ctx, newCacheDir)
// The user is still there
//require.Equal(t, []string{userID}, bridge.GetUserIDs())
//require.Equal(t, []string{userID}, getConnectedUserIDs(t, bridge))
})
})
} */
// withEnv creates the full test environment and runs the tests.
func withEnv(t *testing.T, tests func(context.Context, *server.Server, *proton.NetCtl, bridge.Locator, []byte), opts ...server.Option) {
server := server.New(opts...)