本文整理汇总了Golang中github.com/syncthing/syncthing/internal/config.DeviceConfiguration.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang DeviceConfiguration.Name方法的具体用法?Golang DeviceConfiguration.Name怎么用?Golang DeviceConfiguration.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/syncthing/syncthing/internal/config.DeviceConfiguration
的用法示例。
在下文中一共展示了DeviceConfiguration.Name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestFolderWithoutRestart
func TestFolderWithoutRestart(t *testing.T) {
log.Println("Cleaning...")
err := removeAll("testfolder-p1", "testfolder-p4", "h1/index*", "h4/index*")
if err != nil {
t.Fatal(err)
}
defer removeAll("testfolder-p1", "testfolder-p4")
if err := generateFiles("testfolder-p1", 50, 18, "../LICENSE"); err != nil {
t.Fatal(err)
}
p1 := startInstance(t, 1)
defer checkedStop(t, p1)
p4 := startInstance(t, 4)
defer checkedStop(t, p4)
if ok, err := p1.ConfigInSync(); err != nil || !ok {
t.Fatal("p1 should be in sync;", ok, err)
}
if ok, err := p4.ConfigInSync(); err != nil || !ok {
t.Fatal("p4 should be in sync;", ok, err)
}
// Add a new folder to p1, shared with p4. Back up and restore the config
// first.
log.Println("Adding testfolder to p1...")
os.Remove("h1/config.xml.orig")
os.Rename("h1/config.xml", "h1/config.xml.orig")
defer os.Rename("h1/config.xml.orig", "h1/config.xml")
cfg, err := p1.GetConfig()
if err != nil {
t.Fatal(err)
}
newFolder := config.FolderConfiguration{
ID: "testfolder",
RawPath: "testfolder-p1",
RescanIntervalS: 86400,
Copiers: 1,
Hashers: 1,
Pullers: 1,
Devices: []config.FolderDeviceConfiguration{{DeviceID: p4.ID()}},
}
newDevice := config.DeviceConfiguration{
DeviceID: p4.ID(),
Name: "p4",
Addresses: []string{"dynamic"},
Compression: protocol.CompressMetadata,
}
cfg.Folders = append(cfg.Folders, newFolder)
cfg.Devices = append(cfg.Devices, newDevice)
if err = p1.PostConfig(cfg); err != nil {
t.Fatal(err)
}
// Add a new folder to p4, shared with p1. Back up and restore the config
// first.
log.Println("Adding testfolder to p4...")
os.Remove("h4/config.xml.orig")
os.Rename("h4/config.xml", "h4/config.xml.orig")
defer os.Rename("h4/config.xml.orig", "h4/config.xml")
cfg, err = p4.GetConfig()
if err != nil {
t.Fatal(err)
}
newFolder.RawPath = "testfolder-p4"
newFolder.Devices = []config.FolderDeviceConfiguration{{DeviceID: p1.ID()}}
newDevice.DeviceID = p1.ID()
newDevice.Name = "p1"
newDevice.Addresses = []string{"127.0.0.1:22001"}
cfg.Folders = append(cfg.Folders, newFolder)
cfg.Devices = append(cfg.Devices, newDevice)
if err = p4.PostConfig(cfg); err != nil {
t.Fatal(err)
}
// The change should not require a restart, so the config should be "in sync"
if ok, err := p1.ConfigInSync(); err != nil || !ok {
t.Fatal("p1 should be in sync;", ok, err)
}
if ok, err := p4.ConfigInSync(); err != nil || !ok {
t.Fatal("p4 should be in sync;", ok, err)
}
// The folder should start and scan - wait for the event that signals this
//.........这里部分代码省略.........