fix nil assertion
This commit is contained in:
parent
edaff0ec06
commit
e7c9034d2c
1 changed files with 13 additions and 5 deletions
|
@ -107,11 +107,11 @@ func (ts *TestServer) getSessionVar(w http.ResponseWriter, r *http.Request) {
|
|||
io.WriteString(w, err.Error())
|
||||
return
|
||||
}
|
||||
if v.(string) != "Minule" {
|
||||
if v != nil && v.(string) != "Minule" {
|
||||
fmt.Fprintf(w, "Value of session key: 'Pes' must be 'Minule', not: %s", v)
|
||||
return
|
||||
}
|
||||
if n.(int) != 16 {
|
||||
if n != nil && n.(int) != 16 {
|
||||
fmt.Fprintf(w, "Value of session key: 'Vek' must be '16', not: %d", n)
|
||||
return
|
||||
}
|
||||
|
@ -185,7 +185,10 @@ func (ts *TestServer) sessionGC(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (ts *TestServer) root(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if r.Header.Get("Cookie") != "" {
|
||||
io.WriteString(w, fmt.Sprintf("Cookie send after end session: %v", r.Header.Get("Cookie")))
|
||||
}
|
||||
io.WriteString(w, "OK")
|
||||
}
|
||||
|
||||
func MkRequest(method, path string) (body []byte, err error) {
|
||||
|
@ -274,7 +277,12 @@ func t9(t *testing.T) {
|
|||
if err := CheckRequestOK("/sessionGC"); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//TODO check ck invalidation
|
||||
}
|
||||
|
||||
func t10(t *testing.T) {
|
||||
if err := CheckRequestOK("/"); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// iterate all session storage impls. and run t1 - t7
|
||||
|
@ -289,7 +297,7 @@ func TestRunAll(t *testing.T) {
|
|||
if sm, err = session.NewManager(pn, sid, lifet, true); err != nil {
|
||||
t.Errorf("Session provider %s failed initialize err: %v", pn, err)
|
||||
}
|
||||
fns := []func(t *testing.T){t1, t2, t3, t4, t5, t6, t7, t8, t9}
|
||||
fns := []func(t *testing.T){t1, t2, t3, t4, t5, t6, t7, t8, t9, t10}
|
||||
for idx, fn := range fns {
|
||||
t.Run(fmt.Sprintf("Test%d", idx+1), fn)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue