MCPcopy
hub / github.com/syncthing/syncthing / TestSimpleVersioningVersionCount

Function TestSimpleVersioningVersionCount

lib/versioner/simple_test.go:53–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestSimpleVersioningVersionCount(t *testing.T) {
54 if testing.Short() {
55 t.Skip("Test takes some time, skipping.")
56 }
57
58 dir := t.TempDir()
59
60 cfg := config.FolderConfiguration{
61 FilesystemType: config.FilesystemTypeBasic,
62 Path: dir,
63 Versioning: config.VersioningConfiguration{
64 Params: map[string]string{
65 "keep": "2",
66 },
67 },
68 }
69 fs := cfg.Filesystem()
70
71 v := newSimple(cfg)
72
73 path := "test"
74
75 for i := 1; i <= 3; i++ {
76 f, err := fs.Create(path)
77 if err != nil {
78 t.Error(err)
79 }
80 f.Close()
81 if err := v.Archive(path); err != nil {
82 t.Error(err)
83 }
84
85 n, err := fs.DirNames(DefaultPath)
86 if err != nil {
87 t.Error(err)
88 }
89
90 if len(n) != min(i, 2) {
91 t.Error("Wrong count")
92 }
93
94 time.Sleep(time.Second)
95 }
96}
97
98func TestPathTildes(t *testing.T) {
99 // Test that folder and version paths with leading tildes are expanded

Callers

nothing calls this directly

Calls 8

FilesystemMethod · 0.95
newSimpleFunction · 0.85
ShortMethod · 0.80
CreateMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65
ArchiveMethod · 0.65
DirNamesMethod · 0.65

Tested by

no test coverage detected