Test stat file.
(c *checkv1.C)
| 333 | |
| 334 | // Test stat file. |
| 335 | func (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. |
| 362 | func (s *TestSuite) TestCopy(c *checkv1.C) { |