mirror of
https://github.com/actix/actix-extras.git
synced 2025-07-03 13:06:31 +02:00
Added function to create an empty session for testing
This commit is contained in:
committed by
Yuki Okushi
parent
7267a19b1d
commit
e67e4b027d
@ -75,6 +75,20 @@ struct SessionInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Session {
|
impl Session {
|
||||||
|
|
||||||
|
/// Create an empty session. Appropriate for testing.
|
||||||
|
///
|
||||||
|
/// This session wraps an empty state map and status. It can be instantiated for testing purposes.
|
||||||
|
pub fn empty() -> Session {
|
||||||
|
let inner = SessionInner{
|
||||||
|
state: HashMap::new(),
|
||||||
|
status: SessionStatus::default(),
|
||||||
|
};
|
||||||
|
Session(Rc::new(RefCell::new(inner)))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get a `value` from the session.
|
/// Get a `value` from the session.
|
||||||
///
|
///
|
||||||
/// It returns an error if it fails to deserialize as `T` the JSON value associated with `key`.
|
/// It returns an error if it fails to deserialize as `T` the JSON value associated with `key`.
|
||||||
|
Reference in New Issue
Block a user