MCPcopy
hub / github.com/rclone/rclone / TestNewObject

Function TestNewObject

backend/http/http_internal_test.go:184–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func TestNewObject(t *testing.T) {
185 f := prepare(t)
186
187 o, err := f.NewObject(context.Background(), "four/under four.txt")
188 require.NoError(t, err)
189
190 assert.Equal(t, "four/under four.txt", o.Remote())
191 assert.Equal(t, int64(8+lineEndSize), o.Size())
192 _, ok := o.(*Object)
193 assert.True(t, ok)
194
195 // Test the time is correct on the object
196
197 tObj := o.ModTime(context.Background())
198
199 fi, err := os.Stat(filepath.Join(filesPath, "four", "under four.txt"))
200 require.NoError(t, err)
201 tFile := fi.ModTime()
202
203 fstest.AssertTimeEqualWithPrecision(t, o.Remote(), tFile, tObj, time.Second)
204
205 // check object not found
206 o, err = f.NewObject(context.Background(), "not found.txt")
207 assert.Nil(t, o)
208 assert.Equal(t, fs.ErrorObjectNotFound, err)
209}
210
211func TestNewObjectWithLeadingSlash(t *testing.T) {
212 f := prepare(t)

Callers

nothing calls this directly

Calls 10

RemoteMethod · 0.95
SizeMethod · 0.95
ModTimeMethod · 0.95
JoinMethod · 0.80
prepareFunction · 0.70
NewObjectMethod · 0.65
StatMethod · 0.65
ModTimeMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…