Skip to content

Commit e67e4b0

Browse files
kingledionJohnTitor
authored andcommitted
Added function to create an empty session for testing
1 parent 7267a19 commit e67e4b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

actix-session/src/session.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ struct SessionInner {
7575
}
7676

7777
impl Session {
78+
79+
/// Create an empty session. Appropriate for testing.
80+
///
81+
/// This session wraps an empty state map and status. It can be instantiated for testing purposes.
82+
pub fn empty() -> Session {
83+
let inner = SessionInner{
84+
state: HashMap::new(),
85+
status: SessionStatus::default(),
86+
};
87+
Session(Rc::new(RefCell::new(inner)))
88+
}
89+
90+
91+
7892
/// Get a `value` from the session.
7993
///
8094
/// It returns an error if it fails to deserialize as `T` the JSON value associated with `key`.

0 commit comments

Comments
 (0)