MCPcopy Index your code
hub / github.com/ContentSquare/chproxy / TestGetSessionTimeout

Function TestGetSessionTimeout

utils_test.go:283–315  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

281}
282
283func TestGetSessionTimeout(t *testing.T) {
284 req, err := http.NewRequest(http.MethodPost, "http://127.0.0.1:9090", nil)
285 if err != nil {
286 panic(err)
287 }
288 params := make(url.Values)
289 // uint str return self
290 firstSessionTimeout := "888"
291 // invalid str return 60
292 secondSessionTimeout := "600s"
293 thirdSessionTimeout := "aaa"
294 params.Add("query", "SELECT 1")
295 params.Set("session_timeout", firstSessionTimeout)
296 req.URL.RawQuery = params.Encode()
297 if getSessionTimeout(req) != 888 {
298 t.Fatalf("user set session_timeout %q; get %q , expected %q ", firstSessionTimeout, getSessionTimeout(req), 888)
299 }
300 params.Set("session_timeout", secondSessionTimeout)
301 req.URL.RawQuery = params.Encode()
302 if getSessionTimeout(req) != 60 {
303 t.Fatalf("user set session_timeout %q; get %q , expected %q", secondSessionTimeout, getSessionTimeout(req), 60)
304 }
305 params.Set("session_timeout", thirdSessionTimeout)
306 req.URL.RawQuery = params.Encode()
307 if getSessionTimeout(req) != 60 {
308 t.Fatalf("user set session_timeout %q; get %q , expected %q", thirdSessionTimeout, getSessionTimeout(req), 60)
309 }
310 params.Del("session_timeout")
311 req.URL.RawQuery = params.Encode()
312 if getSessionTimeout(req) != 60 {
313 t.Fatalf("user not set session_timeout ,get %q , expected %q", getSessionTimeout(req), 60)
314 }
315}
316
317func makeQuery(n int) []byte {
318 q1 := "SELECT column "

Callers

nothing calls this directly

Calls 1

getSessionTimeoutFunction · 0.85

Tested by

no test coverage detected