MCPcopy
hub / github.com/syncthing/syncthing / TestCreateVersionPath

Function TestCreateVersionPath

lib/versioner/staggered_test.go:129–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

127}
128
129func TestCreateVersionPath(t *testing.T) {
130 const (
131 versionsDir = "some/nested/dir"
132 archiveFile = "testfile"
133 )
134
135 // Create a test dir and file
136 tmpDir := t.TempDir()
137 if err := os.WriteFile(filepath.Join(tmpDir, archiveFile), []byte("sup"), 0o644); err != nil {
138 t.Fatal(err)
139 }
140
141 folderCfg := config.FolderConfiguration{
142 ID: "default",
143 FilesystemType: config.FilesystemTypeBasic,
144 Path: tmpDir,
145 Versioning: config.VersioningConfiguration{
146 Type: "staggered",
147 FSType: config.FilesystemTypeBasic,
148 FSPath: versionsDir,
149 },
150 }
151
152 // Archive the file
153 versioner := newStaggered(folderCfg)
154 if err := versioner.Archive(archiveFile); err != nil {
155 t.Fatal(err)
156 }
157
158 // Look for files named like the test file, in the archive dir.
159 files, err := filepath.Glob(filepath.Join(tmpDir, versionsDir, archiveFile) + "*")
160 if err != nil {
161 t.Fatal(err)
162 }
163 if len(files) == 0 {
164 t.Error("expected file to have been archived")
165 }
166}

Callers

nothing calls this directly

Calls 5

newStaggeredFunction · 0.85
FatalMethod · 0.80
ArchiveMethod · 0.65
GlobMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected