MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / TestWriteThenReadHeader

Function TestWriteThenReadHeader

cache/tmp_file_response_writer_test.go:98–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestWriteThenReadHeader(t *testing.T) {
99 srw := newFakeResponse()
100
101 tmpFileRespWriter, err := NewTmpFileResponseWriter(srw, testTmpWriterDir)
102 defer tmpFileRespWriter.Close()
103 if err != nil {
104 t.Fatalf("could not initate TmpFileResponseWriter error:%s", err)
105 return
106 }
107 tmpFileRespWriter.Write([]byte("this is a test1 of length 28"))
108
109 cType := tmpFileRespWriter.GetCapturedContentType()
110 cEncoding := tmpFileRespWriter.GetCapturedContentEncoding()
111 cLength, _ := tmpFileRespWriter.GetCapturedContentLength()
112 if err != nil {
113 t.Fatalf("could not get ContentLength error:%s", err)
114 return
115 }
116
117 if cType != "content-type-1" {
118 t.Fatalf("wrong value for contentType, got %s, expected %s", cType, "content-type-1")
119 }
120 if cEncoding != "content-encoding-1" {
121 t.Fatalf("wrong value for contentEncoding, got %s, expected %s", cEncoding, "content-encoding-1")
122 }
123 if cLength != 28 {
124 t.Fatalf("wrong value for contentLength, got %d, expected %d", cLength, 28)
125 }
126
127}
128
129func TestWriteThenReadContent(t *testing.T) {
130 srw := newFakeResponse()

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
WriteMethod · 0.95
newFakeResponseFunction · 0.85
NewTmpFileResponseWriterFunction · 0.85

Tested by

no test coverage detected