MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestFileStorage_OpenWriter

Function TestFileStorage_OpenWriter

internal/caches/storage_file_test.go:55–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestFileStorage_OpenWriter(t *testing.T) {
56 if !testutils.IsSingleTesting() {
57 return
58 }
59
60 var storage = NewFileStorage(&serverconfigs.HTTPCachePolicy{
61 Id: 1,
62 IsOn: true,
63 Options: map[string]interface{}{
64 "dir": Tea.Root + "/caches",
65 },
66 })
67
68 defer storage.Stop()
69
70 err := storage.Init()
71 if err != nil {
72 t.Fatal(err)
73 }
74 now := time.Now()
75 defer func() {
76 t.Log(time.Since(now).Seconds()*1000, "ms")
77 }()
78
79 header := []byte("Header")
80 body := []byte("This is Body")
81 writer, err := storage.OpenWriter("my-key", time.Now().Unix()+86400, 200, -1, -1, -1, false)
82 if err != nil {
83 t.Fatal(err)
84 }
85 t.Log(writer)
86
87 _, err = writer.WriteHeader(header)
88 if err != nil {
89 t.Fatal(err)
90 }
91
92 _, err = writer.Write(body)
93 if err != nil {
94 t.Fatal(err)
95 }
96
97 err = writer.Close()
98 if err != nil {
99 t.Fatal(err)
100 }
101
102 t.Log("header:", writer.HeaderSize(), "body:", writer.BodySize())
103 t.Log("ok")
104}
105
106func TestFileStorage_OpenWriter_Partial(t *testing.T) {
107 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 12

IsSingleTestingFunction · 0.92
NewFileStorageFunction · 0.85
LogMethod · 0.80
UnixMethod · 0.80
StopMethod · 0.65
InitMethod · 0.65
OpenWriterMethod · 0.65
WriteHeaderMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65
HeaderSizeMethod · 0.65
BodySizeMethod · 0.65

Tested by

no test coverage detected