lib/model: Use factories for creating folders
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3029
This commit is contained in:
committed by
Jakob Borg
parent
6720906ee5
commit
eabd2fc936
@@ -34,7 +34,7 @@ func init() {
|
||||
device1, _ = protocol.DeviceIDFromString("AIR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR")
|
||||
device2, _ = protocol.DeviceIDFromString("GYRZZQB-IRNPV4Z-T7TC52W-EQYJ3TT-FDQW6MW-DFLMU42-SSSU6EM-FBK2VAY")
|
||||
|
||||
defaultFolderConfig = config.NewFolderConfiguration("default", "testdata")
|
||||
defaultFolderConfig = config.NewFolderConfiguration("default", "testdata", config.FolderTypeReadWrite)
|
||||
defaultFolderConfig.Devices = []config.FolderDeviceConfiguration{{DeviceID: device1}}
|
||||
_defaultConfig := config.Configuration{
|
||||
Folders: []config.FolderConfiguration{defaultFolderConfig},
|
||||
@@ -85,7 +85,7 @@ func TestRequest(t *testing.T) {
|
||||
|
||||
// device1 shares default, but device2 doesn't
|
||||
m.AddFolder(defaultFolderConfig)
|
||||
m.StartFolderRO("default")
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
m.ScanFolder("default")
|
||||
|
||||
@@ -159,7 +159,7 @@ func benchmarkIndex(b *testing.B, nfiles int) {
|
||||
db := db.OpenMemory()
|
||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "device", "syncthing", "dev", db, nil)
|
||||
m.AddFolder(defaultFolderConfig)
|
||||
m.StartFolderRO("default")
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
|
||||
files := genFiles(nfiles)
|
||||
@@ -188,7 +188,7 @@ func benchmarkIndexUpdate(b *testing.B, nfiles, nufiles int) {
|
||||
db := db.OpenMemory()
|
||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "device", "syncthing", "dev", db, nil)
|
||||
m.AddFolder(defaultFolderConfig)
|
||||
m.StartFolderRO("default")
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
|
||||
files := genFiles(nfiles)
|
||||
@@ -492,7 +492,7 @@ func TestIgnores(t *testing.T) {
|
||||
db := db.OpenMemory()
|
||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "device", "syncthing", "dev", db, nil)
|
||||
m.AddFolder(defaultFolderConfig)
|
||||
m.StartFolderRO("default")
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
|
||||
expected := []string{
|
||||
@@ -609,6 +609,7 @@ func TestROScanRecovery(t *testing.T) {
|
||||
fcfg := config.FolderConfiguration{
|
||||
ID: "default",
|
||||
RawPath: "testdata/rotestfolder",
|
||||
Type: config.FolderTypeReadOnly,
|
||||
RescanIntervalS: 1,
|
||||
}
|
||||
cfg := config.Wrap("/tmp/test", config.Configuration{
|
||||
@@ -624,7 +625,7 @@ func TestROScanRecovery(t *testing.T) {
|
||||
|
||||
m := NewModel(cfg, protocol.LocalDeviceID, "device", "syncthing", "dev", ldb, nil)
|
||||
m.AddFolder(fcfg)
|
||||
m.StartFolderRO("default")
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
|
||||
waitFor := func(status string) error {
|
||||
@@ -693,6 +694,7 @@ func TestRWScanRecovery(t *testing.T) {
|
||||
fcfg := config.FolderConfiguration{
|
||||
ID: "default",
|
||||
RawPath: "testdata/rwtestfolder",
|
||||
Type: config.FolderTypeReadWrite,
|
||||
RescanIntervalS: 1,
|
||||
}
|
||||
cfg := config.Wrap("/tmp/test", config.Configuration{
|
||||
@@ -708,7 +710,7 @@ func TestRWScanRecovery(t *testing.T) {
|
||||
|
||||
m := NewModel(cfg, protocol.LocalDeviceID, "device", "syncthing", "dev", ldb, nil)
|
||||
m.AddFolder(fcfg)
|
||||
m.StartFolderRW("default")
|
||||
m.StartFolder("default")
|
||||
m.ServeBackground()
|
||||
|
||||
waitFor := func(status string) error {
|
||||
@@ -1219,7 +1221,7 @@ func TestIgnoreDelete(t *testing.T) {
|
||||
|
||||
m.AddFolder(cfg)
|
||||
m.ServeBackground()
|
||||
m.StartFolderRW("default")
|
||||
m.StartFolder("default")
|
||||
m.ScanFolder("default")
|
||||
|
||||
// Get a currently existing file
|
||||
|
||||
Reference in New Issue
Block a user