Exemple #1
0
func TestNewSession(t *testing.T) {
	eq, neq := mighty.EqNeq(t)
	ss := []Session{NewSession(), NewSessionOptions(&SessOptions{})}

	for _, s := range ss {
		eq(true, s.New())
		eq(s.Accessed(), s.Created())
		eq(0, len(s.Attrs()))
		neq(nil, s.Mutex())

		time.Sleep(10 * time.Millisecond)
		s.Access()
		neq(s.Accessed(), s.Created())
	}
}
Exemple #2
0
func TestInMemStore(t *testing.T) {
	eq, neq := mighty.EqNeq(t)

	st := NewInMemStore()
	defer st.Close()

	eq(nil, st.Get("asdf"))

	s := NewSession()
	st.Add(s)
	time.Sleep(10 * time.Millisecond)
	eq(s, st.Get(s.Id()))
	neq(s.Accessed(), s.Created())

	st.Remove(s)
	eq(nil, st.Get(s.Id()))
}