all: Use protobuf to generate config structs (fixes #6734) (#6900)

This commit is contained in:
Audrius Butkevicius
2020-08-25 08:11:14 +02:00
committed by GitHub
parent 5b953033c7
commit d507d932b8
84 changed files with 3807 additions and 542 deletions
+12 -13
View File
@@ -21,6 +21,7 @@ import (
"testing"
"github.com/d4l3k/messagediff"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/protocol"
@@ -523,9 +524,6 @@ func TestNewSaveLoad(t *testing.T) {
intCfg := New(device1)
cfg := wrap(path, intCfg)
// To make the equality pass later
cfg.(*wrapper).cfg.XMLName.Local = "configuration"
if exists(path) {
t.Error(path, "exists")
}
@@ -614,14 +612,14 @@ func TestPullOrder(t *testing.T) {
name string
order PullOrder
}{
{"f1", OrderRandom}, // empty value, default
{"f2", OrderRandom}, // explicit
{"f3", OrderAlphabetic}, // explicit
{"f4", OrderRandom}, // unknown value, default
{"f5", OrderSmallestFirst}, // explicit
{"f6", OrderLargestFirst}, // explicit
{"f7", OrderOldestFirst}, // explicit
{"f8", OrderNewestFirst}, // explicit
{"f1", PullOrderRandom}, // empty value, default
{"f2", PullOrderRandom}, // explicit
{"f3", PullOrderAlphabetic}, // explicit
{"f4", PullOrderRandom}, // unknown value, default
{"f5", PullOrderSmallestFirst}, // explicit
{"f6", PullOrderLargestFirst}, // explicit
{"f7", PullOrderOldestFirst}, // explicit
{"f8", PullOrderNewestFirst}, // explicit
}
// Verify values are deserialized correctly
@@ -640,7 +638,7 @@ func TestPullOrder(t *testing.T) {
t.Logf("%s", buf.Bytes())
cfg, err = ReadXML(buf, device1)
cfg, _, err = ReadXML(buf, device1)
if err != nil {
t.Fatal(err)
}
@@ -1169,7 +1167,8 @@ func defaultConfigAsMap() map[string]interface{} {
}
func load(path string, myID protocol.DeviceID) (Wrapper, error) {
return Load(path, myID, events.NoopLogger)
cfg, _, err := Load(path, myID, events.NoopLogger)
return cfg, err
}
func wrap(path string, cfg Configuration) Wrapper {