(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func 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 | } |
nothing calls this directly
no test coverage detected