MCPcopy
hub / github.com/rclone/rclone / TestReadFileHandleMethods

Function TestReadFileHandleMethods

vfs/read_test.go:39–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestReadFileHandleMethods(t *testing.T) {
40 _, _, fh := readHandleCreate(t)
41
42 // String
43 assert.Equal(t, "dir/file1 (r)", fh.String())
44 assert.Equal(t, "<nil *ReadFileHandle>", (*ReadFileHandle)(nil).String())
45 assert.Equal(t, "<nil *ReadFileHandle.file>", new(ReadFileHandle).String())
46
47 // Name
48 assert.Equal(t, "dir/file1", fh.Name())
49
50 // Node
51 node := fh.Node()
52 assert.Equal(t, "file1", node.Name())
53
54 // Size
55 assert.Equal(t, int64(16), fh.Size())
56
57 // Read 1
58 assert.Equal(t, "0", readString(t, fh, 1))
59
60 // Read remainder
61 assert.Equal(t, "123456789abcdef", readString(t, fh, 256))
62
63 // Read EOF
64 buf := make([]byte, 16)
65 _, err := fh.Read(buf)
66 assert.Equal(t, io.EOF, err)
67
68 // Stat
69 var fi os.FileInfo
70 fi, err = fh.Stat()
71 assert.NoError(t, err)
72 assert.Equal(t, int64(16), fi.Size())
73 assert.Equal(t, "file1", fi.Name())
74
75 // Close
76 assert.False(t, fh.closed)
77 assert.Equal(t, nil, fh.Close())
78 assert.True(t, fh.closed)
79
80 // Close again
81 assert.Equal(t, ECLOSED, fh.Close())
82}
83
84func TestReadFileHandleSeek(t *testing.T) {
85 _, _, fh := readHandleCreate(t)

Callers

nothing calls this directly

Calls 12

SizeMethod · 0.95
NameMethod · 0.95
readHandleCreateFunction · 0.85
readStringFunction · 0.85
StringMethod · 0.65
NameMethod · 0.65
NodeMethod · 0.65
SizeMethod · 0.65
ReadMethod · 0.65
StatMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…