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

Function TestAppend

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

Source from the content-addressed store, hash-verified

342}
343
344func TestAppend(t *testing.T) {
345 initDb(t)
346 defer cleanupDb(t)
347
348 ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
349 defer cancelFn()
350 zoneId := uuid.NewString()
351 fileName := "t2"
352 err := WFS.MakeFile(ctx, zoneId, fileName, nil, wshrpc.FileOpts{})
353 if err != nil {
354 t.Fatalf("error creating file: %v", err)
355 }
356 err = WFS.AppendData(ctx, zoneId, fileName, []byte("hello"))
357 if err != nil {
358 t.Fatalf("error appending data: %v", err)
359 }
360 // fmt.Print(GBS.dump())
361 checkFileSize(t, ctx, zoneId, fileName, 5)
362 checkFileData(t, ctx, zoneId, fileName, "hello")
363 err = WFS.AppendData(ctx, zoneId, fileName, []byte(" world"))
364 if err != nil {
365 t.Fatalf("error appending data: %v", err)
366 }
367 // fmt.Print(GBS.dump())
368 checkFileSize(t, ctx, zoneId, fileName, 11)
369 checkFileData(t, ctx, zoneId, fileName, "hello world")
370}
371
372func TestWriteFile(t *testing.T) {
373 initDb(t)

Callers

nothing calls this directly

Calls 6

initDbFunction · 0.85
cleanupDbFunction · 0.85
checkFileDataFunction · 0.85
MakeFileMethod · 0.80
AppendDataMethod · 0.80
checkFileSizeFunction · 0.70

Tested by

no test coverage detected