(t *testing.T)
| 174 | ) |
| 175 | |
| 176 | func TestDecompression(t *testing.T) { |
| 177 | testCases := []struct { |
| 178 | name string |
| 179 | compressedQuery string |
| 180 | f func(*http.Request) error |
| 181 | }{ |
| 182 | { |
| 183 | "full LZ4", |
| 184 | lz4TestQuery, |
| 185 | func(req *http.Request) error { |
| 186 | q, err := getFullQuery(req) |
| 187 | if err != nil { |
| 188 | return err |
| 189 | } |
| 190 | checkResponse(t, req.Body, lz4TestQuery) |
| 191 | if string(q) != testQuery { |
| 192 | return fmt.Errorf("got: %q; expected %q", string(q), testQuery) |
| 193 | } |
| 194 | return nil |
| 195 | }, |
| 196 | }, |
| 197 | { |
| 198 | "snippet LZ4", |
| 199 | lz4TestQuery, |
| 200 | func(req *http.Request) error { |
| 201 | q := getQuerySnippet(req) |
| 202 | if q[:100] != string(testQuery[:100]) { |
| 203 | return fmt.Errorf("got: %q; expected: %q", q[:100], testQuery[:100]) |
| 204 | } |
| 205 | return nil |
| 206 | }, |
| 207 | }, |
| 208 | { |
| 209 | "partial LZ4", |
| 210 | lz4TestQuery + "foobar", // write whatever to buf to make the data partially invalid |
| 211 | func(req *http.Request) error { |
| 212 | q := getQuerySnippet(req) |
| 213 | if q[:50] != testQuery[:50] { |
| 214 | return fmt.Errorf("got: %q; expected: %q", q[:50], testQuery[:50]) |
| 215 | } |
| 216 | return nil |
| 217 | }, |
| 218 | }, |
| 219 | { |
| 220 | "invalid compression", |
| 221 | "foobar", // write totally invalid data and treat it as compressed |
| 222 | func(req *http.Request) error { |
| 223 | q := getQuerySnippet(req) |
| 224 | if q != "foobar" { |
| 225 | t.Fatalf("got: %q; expected: %q", q, "foobar") |
| 226 | } |
| 227 | return nil |
| 228 | }, |
| 229 | }, |
| 230 | { |
| 231 | "full ZSTD", |
| 232 | zstdTestQuery, |
| 233 | func(req *http.Request) error { |
nothing calls this directly
no test coverage detected