(t *testing.T)
| 577 | } |
| 578 | |
| 579 | func TestSimpleDBFlush(t *testing.T) { |
| 580 | initDb(t) |
| 581 | defer cleanupDb(t) |
| 582 | |
| 583 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 584 | defer cancelFn() |
| 585 | zoneId := uuid.NewString() |
| 586 | fileName := "t1" |
| 587 | err := WFS.MakeFile(ctx, zoneId, fileName, nil, wshrpc.FileOpts{}) |
| 588 | if err != nil { |
| 589 | t.Fatalf("error creating file: %v", err) |
| 590 | } |
| 591 | err = WFS.WriteFile(ctx, zoneId, fileName, []byte("hello world!")) |
| 592 | if err != nil { |
| 593 | t.Fatalf("error writing data: %v", err) |
| 594 | } |
| 595 | checkFileData(t, ctx, zoneId, fileName, "hello world!") |
| 596 | _, err = WFS.FlushCache(ctx) |
| 597 | if err != nil { |
| 598 | t.Fatalf("error flushing cache: %v", err) |
| 599 | } |
| 600 | if WFS.getCacheSize() != 0 { |
| 601 | t.Errorf("cache size mismatch") |
| 602 | } |
| 603 | checkFileData(t, ctx, zoneId, fileName, "hello world!") |
| 604 | if WFS.getCacheSize() != 0 { |
| 605 | t.Errorf("cache size mismatch (after read)") |
| 606 | } |
| 607 | checkFileDataAt(t, ctx, zoneId, fileName, 6, "world!") |
| 608 | checkFileSize(t, ctx, zoneId, fileName, 12) |
| 609 | checkFileByteCount(t, ctx, zoneId, fileName, 'l', 3) |
| 610 | } |
| 611 | |
| 612 | func TestConcurrentAppend(t *testing.T) { |
| 613 | initDb(t) |
nothing calls this directly
no test coverage detected