mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Test maps and versioning config
This commit is contained in:
parent
73f5c47fe2
commit
244f0ffaf1
@ -1,3 +1,7 @@
|
||||
// Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
|
||||
// All rights reserved. Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package beacon
|
||||
|
||||
import (
|
||||
|
@ -131,6 +131,13 @@ func TestNodeConfig(t *testing.T) {
|
||||
if !reflect.DeepEqual(cfg.Repositories[0].NodeIDs(), expectedNodeIDs) {
|
||||
t.Errorf("%d: Incorrect NodeIDs\n A: %#v\n E: %#v", i, cfg.Repositories[0].NodeIDs(), expectedNodeIDs)
|
||||
}
|
||||
|
||||
if len(cfg.NodeMap()) != len(expectedNodes) {
|
||||
t.Errorf("Unexpected number of NodeMap() entries")
|
||||
}
|
||||
if len(cfg.RepoMap()) != len(expectedRepos) {
|
||||
t.Errorf("Unexpected number of RepoMap() entries")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,3 +298,37 @@ func TestNodeAddressesStatic(t *testing.T) {
|
||||
t.Errorf("Nodes differ;\n E: %#v\n A: %#v", expected, cfg.Nodes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersioningConfig(t *testing.T) {
|
||||
data := []byte(`
|
||||
<configuration version="2">
|
||||
<repository id="test" directory="~/Sync" ro="true">
|
||||
<versioning type="simple">
|
||||
<param key="foo" val="bar"/>
|
||||
<param key="baz" val="quux"/>
|
||||
</versioning>
|
||||
</repository>
|
||||
</configuration>
|
||||
`)
|
||||
|
||||
cfg, err := Load(bytes.NewReader(data), node4)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
vc := cfg.Repositories[0].Versioning
|
||||
if vc.Type != "simple" {
|
||||
t.Errorf(`vc.Type %q != "simple"`, vc.Type)
|
||||
}
|
||||
if l := len(vc.Params); l != 2 {
|
||||
t.Errorf("len(vc.Params) %d != 2", l)
|
||||
}
|
||||
|
||||
expected := map[string]string{
|
||||
"foo": "bar",
|
||||
"baz": "quux",
|
||||
}
|
||||
if !reflect.DeepEqual(vc.Params, expected) {
|
||||
t.Errorf("vc.Params differ;\n E: %#v\n A: %#v", expected, vc.Params)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user