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

Function TestMultiPart

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

Source from the content-addressed store, hash-verified

501}
502
503func TestMultiPart(t *testing.T) {
504 initDb(t)
505 defer cleanupDb(t)
506
507 ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
508 defer cancelFn()
509 zoneId := uuid.NewString()
510 fileName := "m2"
511 data := makeText(80)
512 err := WFS.MakeFile(ctx, zoneId, fileName, nil, wshrpc.FileOpts{})
513 if err != nil {
514 t.Fatalf("error creating file: %v", err)
515 }
516 err = WFS.AppendData(ctx, zoneId, fileName, []byte(data))
517 if err != nil {
518 t.Fatalf("error appending data: %v", err)
519 }
520 checkFileSize(t, ctx, zoneId, fileName, 80)
521 checkFileData(t, ctx, zoneId, fileName, data)
522 _, barr, err := WFS.ReadAt(ctx, zoneId, fileName, 42, 10)
523 if err != nil {
524 t.Fatalf("error reading data: %v", err)
525 }
526 if string(barr) != data[42:52] {
527 t.Errorf("data mismatch: expected %q, got %q", data[42:52], string(barr))
528 }
529 WFS.WriteAt(ctx, zoneId, fileName, 49, []byte("world"))
530 checkFileSize(t, ctx, zoneId, fileName, 80)
531 checkFileDataAt(t, ctx, zoneId, fileName, 49, "world")
532 checkFileDataAt(t, ctx, zoneId, fileName, 48, "8world4")
533}
534
535func testIntMapsEq(t *testing.T, msg string, m map[int]int, expected map[int]int) {
536 if len(m) != len(expected) {

Callers

nothing calls this directly

Calls 10

initDbFunction · 0.85
cleanupDbFunction · 0.85
makeTextFunction · 0.85
checkFileDataFunction · 0.85
checkFileDataAtFunction · 0.85
MakeFileMethod · 0.80
AppendDataMethod · 0.80
ReadAtMethod · 0.80
WriteAtMethod · 0.80
checkFileSizeFunction · 0.70

Tested by

no test coverage detected