MCPcopy Index your code
hub / github.com/minio/mc / TestStatObject

Method TestStatObject

cmd/client-fs_test.go:335–359  ·  view source on GitHub ↗

Test stat file.

(c *checkv1.C)

Source from the content-addressed store, hash-verified

333
334// Test stat file.
335func (s *TestSuite) TestStatObject(c *checkv1.C) {
336 root, e := os.MkdirTemp(os.TempDir(), "fs-")
337 c.Assert(e, checkv1.IsNil)
338 defer os.RemoveAll(root)
339
340 objectPath := filepath.Join(root, "object")
341 fsClient, err := fsNew(objectPath)
342 c.Assert(err, checkv1.IsNil)
343
344 data := "hello"
345 dataLen := len(data)
346 reader := bytes.NewReader([]byte(data))
347 n, err := fsClient.Put(context.Background(), reader, int64(dataLen), nil, PutOptions{
348 metadata: map[string]string{
349 "Content-Type": "application/octet-stream",
350 },
351 },
352 )
353 c.Assert(err, checkv1.IsNil)
354 c.Assert(n, checkv1.Equals, int64(len(data)))
355
356 content, err := fsClient.Stat(context.Background(), StatOptions{})
357 c.Assert(err, checkv1.IsNil)
358 c.Assert(content.Size, checkv1.Equals, int64(dataLen))
359}
360
361// Test copy.
362func (s *TestSuite) TestCopy(c *checkv1.C) {

Callers

nothing calls this directly

Calls 4

fsNewFunction · 0.85
JoinMethod · 0.80
PutMethod · 0.65
StatMethod · 0.65

Tested by

no test coverage detected