MCPcopy
hub / github.com/restic/restic / TestRESTLayoutURLs

Function TestRESTLayoutURLs

internal/backend/layout/layout_test.go:208–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func TestRESTLayoutURLs(t *testing.T) {
209 var tests = []struct {
210 l Layout
211 h backend.Handle
212 fn string
213 dir string
214 }{
215 {
216 &RESTLayout{url: "https://hostname.foo"},
217 backend.Handle{Type: backend.PackFile, Name: "foobar"},
218 "https://hostname.foo/data/foobar",
219 "https://hostname.foo/data/",
220 },
221 {
222 &RESTLayout{url: "https://hostname.foo:1234/prefix/repo"},
223 backend.Handle{Type: backend.LockFile, Name: "foobar"},
224 "https://hostname.foo:1234/prefix/repo/locks/foobar",
225 "https://hostname.foo:1234/prefix/repo/locks/",
226 },
227 {
228 &RESTLayout{url: "https://hostname.foo:1234/prefix/repo"},
229 backend.Handle{Type: backend.ConfigFile, Name: "foobar"},
230 "https://hostname.foo:1234/prefix/repo/config",
231 "https://hostname.foo:1234/prefix/repo/",
232 },
233 }
234
235 for _, test := range tests {
236 t.Run(fmt.Sprintf("%T", test.l), func(t *testing.T) {
237 fn := test.l.Filename(test.h)
238 if fn != test.fn {
239 t.Fatalf("wrong filename, want %v, got %v", test.fn, fn)
240 }
241
242 dir := test.l.Dirname(test.h)
243 if dir != test.dir {
244 t.Fatalf("wrong dirname, want %v, got %v", test.dir, dir)
245 }
246 })
247 }
248}

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
FatalfMethod · 0.80
FilenameMethod · 0.65
DirnameMethod · 0.65

Tested by

no test coverage detected