This commit is contained in:
@@ -9,6 +9,7 @@ package config
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -1173,3 +1174,36 @@ func load(path string, myID protocol.DeviceID) (Wrapper, error) {
|
||||
func wrap(path string, cfg Configuration) Wrapper {
|
||||
return Wrap(path, cfg, events.NoopLogger)
|
||||
}
|
||||
|
||||
func TestInternalVersioningConfiguration(t *testing.T) {
|
||||
// Verify that the versioning configuration XML seralizes to something
|
||||
// reasonable.
|
||||
|
||||
cfg := New(device1)
|
||||
cfg.Folders = append(cfg.Folders, NewFolderConfiguration(device1, "default", "default", fs.FilesystemTypeBasic, "/tmp"))
|
||||
cfg.Folders[0].Versioning = VersioningConfiguration{
|
||||
Type: "foo",
|
||||
Params: map[string]string{"bar": "baz"},
|
||||
CleanupIntervalS: 42,
|
||||
}
|
||||
|
||||
// These things should all be present in the serialized version.
|
||||
expected := []string{
|
||||
`<versioning type="foo">`,
|
||||
`<param key="bar" val="baz"`,
|
||||
`<cleanupIntervalS>42<`,
|
||||
`</versioning>`,
|
||||
}
|
||||
|
||||
bs, err := xml.MarshalIndent(cfg, "", " ")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, exp := range expected {
|
||||
if !strings.Contains(string(bs), exp) {
|
||||
t.Logf("%s", bs)
|
||||
t.Fatal("bad serializion of versioning parameters")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user