MCPcopy
hub / github.com/rclone/rclone / TestRWFileHandleMethodsRead

Function TestRWFileHandleMethodsRead

vfs/read_write_test.go:71–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestRWFileHandleMethodsRead(t *testing.T) {
72 _, _, fh := rwHandleCreateReadOnly(t)
73
74 // String
75 assert.Equal(t, "dir/file1 (rw)", fh.String())
76 assert.Equal(t, "<nil *RWFileHandle>", (*RWFileHandle)(nil).String())
77 assert.Equal(t, "<nil *RWFileHandle.file>", new(RWFileHandle).String())
78
79 // Node
80 node := fh.Node()
81 assert.Equal(t, "file1", node.Name())
82
83 // Size
84 assert.Equal(t, int64(16), fh.Size())
85
86 // Read 1
87 assert.Equal(t, "0", rwReadString(t, fh, 1))
88
89 // Read remainder
90 assert.Equal(t, "123456789abcdef", rwReadString(t, fh, 256))
91
92 // Read EOF
93 buf := make([]byte, 16)
94 _, err := fh.Read(buf)
95 assert.Equal(t, io.EOF, err)
96
97 // Sync
98 err = fh.Sync()
99 assert.NoError(t, err)
100
101 // Stat
102 var fi os.FileInfo
103 fi, err = fh.Stat()
104 assert.NoError(t, err)
105 assert.Equal(t, int64(16), fi.Size())
106 assert.Equal(t, "file1", fi.Name())
107
108 // Close
109 assert.False(t, fh.closed)
110 assert.Equal(t, nil, fh.Close())
111 assert.True(t, fh.closed)
112
113 // Close again
114 assert.Equal(t, ECLOSED, fh.Close())
115}
116
117func TestRWFileHandleSeek(t *testing.T) {
118 _, _, fh := rwHandleCreateReadOnly(t)

Callers

nothing calls this directly

Calls 13

SizeMethod · 0.95
NameMethod · 0.95
rwHandleCreateReadOnlyFunction · 0.85
rwReadStringFunction · 0.85
StringMethod · 0.65
NodeMethod · 0.65
NameMethod · 0.65
SizeMethod · 0.65
ReadMethod · 0.65
SyncMethod · 0.65
StatMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…