MCPcopy
hub / github.com/syncthing/syncthing / loadConfig

Function loadConfig

lib/model/model_test.go:360–376  ·  view source on GitHub ↗

Adjusted copy of the original function for testing purposes

(ffs fs.Filesystem, path string, myID protocol.DeviceID, evLogger events.Logger)

Source from the content-addressed store, hash-verified

358
359// Adjusted copy of the original function for testing purposes
360func loadConfig(ffs fs.Filesystem, path string, myID protocol.DeviceID, evLogger events.Logger) (config.Wrapper, int, error) {
361 if _, err := ffs.Lstat(path); err != nil {
362 return nil, 0, err
363 }
364 fd, err := ffs.OpenFile(path, fs.OptReadWrite, 0o666)
365 if err != nil {
366 return nil, 0, err
367 }
368 defer fd.Close()
369
370 cfg, originalVersion, err := config.ReadXML(fd, myID)
371 if err != nil {
372 return nil, 0, err
373 }
374
375 return config.Wrap(path, cfg, myID, evLogger), originalVersion, nil
376}
377
378func TestClusterConfig(t *testing.T) {
379 cfg := config.New(device1)

Callers 1

TestDeviceRenameFunction · 0.85

Calls 5

ReadXMLFunction · 0.92
WrapFunction · 0.92
LstatMethod · 0.65
OpenFileMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected