MCPcopy
hub / github.com/rclone/rclone / TestVFSStat

Function TestVFSStat

vfs/vfs_test.go:185–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestVFSStat(t *testing.T) {
186 r, vfs := newTestVFS(t)
187
188 file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
189 file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
190 r.CheckRemoteItems(t, file1, file2)
191
192 node, err := vfs.Stat("file1")
193 require.NoError(t, err)
194 assert.True(t, node.IsFile())
195 assert.Equal(t, "file1", node.Name())
196
197 node, err = vfs.Stat("dir")
198 require.NoError(t, err)
199 assert.True(t, node.IsDir())
200 assert.Equal(t, "dir", node.Name())
201
202 node, err = vfs.Stat("dir/file2")
203 require.NoError(t, err)
204 assert.True(t, node.IsFile())
205 assert.Equal(t, "file2", node.Name())
206
207 _, err = vfs.Stat("not found")
208 assert.Equal(t, os.ErrNotExist, err)
209
210 _, err = vfs.Stat("dir/not found")
211 assert.Equal(t, os.ErrNotExist, err)
212
213 _, err = vfs.Stat("not found/not found")
214 assert.Equal(t, os.ErrNotExist, err)
215
216 _, err = vfs.Stat("file1/under a file")
217 assert.Equal(t, os.ErrNotExist, err)
218}
219
220func TestVFSStatParent(t *testing.T) {
221 r, vfs := newTestVFS(t)

Callers

nothing calls this directly

Calls 8

newTestVFSFunction · 0.85
WriteObjectMethod · 0.80
CheckRemoteItemsMethod · 0.80
StatMethod · 0.65
IsFileMethod · 0.65
NameMethod · 0.65
EqualMethod · 0.45
IsDirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…