lib/model: Support removing paused folders (fixes #4357)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4358 LGTM: imsodin, calmh
This commit is contained in:
committed by
Jakob Borg
parent
283c8d95e2
commit
e85ce7c94e
@@ -1902,6 +1902,52 @@ func TestIssue3164(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue4357(t *testing.T) {
|
||||
db := db.OpenMemory()
|
||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||
m.ServeBackground()
|
||||
defer m.Stop()
|
||||
cfg := m.cfg.RawCopy()
|
||||
m.CommitConfiguration(config.Configuration{}, cfg)
|
||||
|
||||
if _, ok := m.folderCfgs["default"]; !ok {
|
||||
t.Error("Folder should be running")
|
||||
}
|
||||
|
||||
newCfg := m.cfg.RawCopy()
|
||||
newCfg.Folders[0].Paused = true
|
||||
m.CommitConfiguration(cfg, newCfg)
|
||||
|
||||
if _, ok := m.folderCfgs["default"]; ok {
|
||||
t.Error("Folder should not be running")
|
||||
}
|
||||
|
||||
// Should not panic when removing a paused folder.
|
||||
m.RemoveFolder("default")
|
||||
|
||||
// Add the folder back, should be running
|
||||
m.CommitConfiguration(config.Configuration{}, cfg)
|
||||
|
||||
if _, ok := m.folderCfgs["default"]; !ok {
|
||||
t.Error("Folder should be running")
|
||||
}
|
||||
|
||||
// Should not panic when removing a running folder.
|
||||
m.RemoveFolder("default")
|
||||
if _, ok := m.folderCfgs["default"]; ok {
|
||||
t.Error("Folder should not be running")
|
||||
}
|
||||
|
||||
// Should panic when removing a non-existing folder
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
t.Error("expected a panic")
|
||||
}
|
||||
}()
|
||||
m.RemoveFolder("non-existing")
|
||||
|
||||
}
|
||||
|
||||
func TestScanNoDatabaseWrite(t *testing.T) {
|
||||
// When scanning, nothing should be committed to database unless
|
||||
// something actually changed.
|
||||
|
||||
Reference in New Issue
Block a user