MCPcopy Index your code
hub / github.com/rclone/rclone / TestCacheRename

Function TestCacheRename

lib/cache/cache_test.go:318–351  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

316}
317
318func TestCacheRename(t *testing.T) {
319 c := New()
320 create := func(path string) (any, bool, error) {
321 return path, true, nil
322 }
323
324 existing1, err := c.Get("existing1", create)
325 require.NoError(t, err)
326 _, err = c.Get("existing2", create)
327 require.NoError(t, err)
328
329 assert.Equal(t, 2, c.Entries())
330
331 // rename to nonexistent
332 value, found := c.Rename("existing1", "EXISTING1")
333 assert.Equal(t, true, found)
334 assert.Equal(t, existing1, value)
335
336 assert.Equal(t, 2, c.Entries())
337
338 // rename to existent and check existing value is returned
339 value, found = c.Rename("existing2", "EXISTING1")
340 assert.Equal(t, true, found)
341 assert.Equal(t, existing1, value)
342
343 assert.Equal(t, 1, c.Entries())
344
345 // rename nonexistent
346 value, found = c.Rename("notfound", "NOTFOUND")
347 assert.Equal(t, false, found)
348 assert.Nil(t, value)
349
350 assert.Equal(t, 1, c.Entries())
351}
352
353func TestCacheFinalize(t *testing.T) {
354 c := New()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
GetMethod · 0.65
RenameMethod · 0.65
EqualMethod · 0.45
EntriesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…