MCPcopy
hub / github.com/wavetermdev/waveterm / TestSimpleDBFlush

Function TestSimpleDBFlush

pkg/filestore/blockstore_test.go:579–610  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

577}
578
579func 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
612func TestConcurrentAppend(t *testing.T) {
613 initDb(t)

Callers

nothing calls this directly

Calls 10

initDbFunction · 0.85
cleanupDbFunction · 0.85
checkFileDataFunction · 0.85
checkFileDataAtFunction · 0.85
checkFileByteCountFunction · 0.85
MakeFileMethod · 0.80
WriteFileMethod · 0.80
FlushCacheMethod · 0.80
getCacheSizeMethod · 0.80
checkFileSizeFunction · 0.70

Tested by

no test coverage detected