MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestNewFileWriter_LargeFile

Function TestNewFileWriter_LargeFile

internal/utils/bfs/file_writer_test.go:60–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestNewFileWriter_LargeFile(t *testing.T) {
61 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)
62 if err != nil {
63 t.Fatal(err)
64 }
65
66 defer func() {
67 if !testutils.IsSingleTesting() {
68 _ = bFile.RemoveAll()
69 } else {
70 _ = bFile.Close()
71 }
72 }()
73
74 writer, err := bFile.OpenFileWriter(bfs.Hash("123456@LARGE"), -1, false)
75 if err != nil {
76 t.Fatal(err)
77 }
78
79 err = writer.WriteMeta(http.StatusOK, fasttime.Now().Unix()+86400, -1)
80 if err != nil {
81 t.Fatal(err)
82 }
83
84 var countBlocks = 1 << 10
85 if !testutils.IsSingleTesting() {
86 countBlocks = 2
87 }
88
89 var data = bytes.Repeat([]byte{'A'}, 16<<10)
90
91 var before = time.Now()
92 for i := 0; i < countBlocks; i++ {
93 _, err = writer.WriteBody(data)
94 if err != nil {
95 t.Fatal(err)
96 }
97 }
98
99 err = writer.Close()
100 if err != nil {
101 t.Fatal(err)
102 }
103
104 logs.Println("cost:", time.Since(before).Seconds()*1000, "ms")
105}
106
107func TestFileWriter_WriteBodyAt(t *testing.T) {
108 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)

Callers

nothing calls this directly

Calls 10

OpenBlocksFileFunction · 0.92
IsSingleTestingFunction · 0.92
HashFunction · 0.92
NowFunction · 0.92
UnixMethod · 0.80
WriteBodyMethod · 0.80
CloseMethod · 0.65
RemoveAllMethod · 0.45
OpenFileWriterMethod · 0.45
WriteMetaMethod · 0.45

Tested by

no test coverage detected