GODT-976 Exclude updates from clearing cache and clear cache, including updates, while switching early access off

This commit is contained in:
Michal Horejsek
2021-01-27 09:16:04 +01:00
parent c6107dbd4b
commit 7468ed7dc0
18 changed files with 241 additions and 13 deletions

View File

@ -68,5 +68,7 @@ func newBridgeInstance(
clientManager users.ClientManager,
) *bridge.Bridge {
panicHandler := &panicHandler{t: t}
return bridge.New(locations, cache, settings, panicHandler, eventListener, clientManager, credStore)
updater := newFakeUpdater()
versioner := newFakeVersioner()
return bridge.New(locations, cache, settings, panicHandler, eventListener, clientManager, credStore, updater, versioner)
}

View File

@ -48,3 +48,7 @@ func (l *fakeLocations) ProvideSettingsPath() (string, error) {
func (l *fakeLocations) Clear() error {
return os.RemoveAll(l.dir)
}
func (l *fakeLocations) ClearUpdates() error {
return nil
}

41
test/context/updater.go Normal file
View File

@ -0,0 +1,41 @@
// Copyright (c) 2021 Proton Technologies AG
//
// This file is part of ProtonMail Bridge.Bridge.
//
// ProtonMail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ProtonMail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
package context
import (
"github.com/ProtonMail/proton-bridge/internal/updater"
)
type fakeUpdater struct{}
// newFakeUpdater creates an empty updater just to fulfill Bridge dependencies.
func newFakeUpdater() *fakeUpdater {
return &fakeUpdater{}
}
func (c *fakeUpdater) Check() (updater.VersionInfo, error) {
return updater.VersionInfo{}, nil
}
func (c *fakeUpdater) IsDowngrade(_ updater.VersionInfo) bool {
return false
}
func (c *fakeUpdater) InstallUpdate(_ updater.VersionInfo) error {
return nil
}

33
test/context/versioner.go Normal file
View File

@ -0,0 +1,33 @@
// Copyright (c) 2021 Proton Technologies AG
//
// This file is part of ProtonMail Bridge.Bridge.
//
// ProtonMail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ProtonMail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
package context
import (
"github.com/Masterminds/semver/v3"
)
type fakeVersioner struct{}
// newFakeVersioner creates an empty versioner just to fulfill Bridge dependencies.
func newFakeVersioner() *fakeVersioner {
return &fakeVersioner{}
}
func (c *fakeVersioner) RemoveOtherVersions(_ *semver.Version) error {
return nil
}