From e67e4b027d6030feabac3eeb0b4cf068b26b901b Mon Sep 17 00:00:00 2001 From: "daniel.hartig" Date: Fri, 10 Jun 2022 18:43:00 -0500 Subject: [PATCH 1/4] Added function to create an empty session for testing --- actix-session/src/session.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/actix-session/src/session.rs b/actix-session/src/session.rs index 2aa3bae680..87505bda19 100644 --- a/actix-session/src/session.rs +++ b/actix-session/src/session.rs @@ -75,6 +75,20 @@ struct SessionInner { } 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. /// /// It returns an error if it fails to deserialize as `T` the JSON value associated with `key`. From f4742847a5f6e4baf9634584f525853f4656977f Mon Sep 17 00:00:00 2001 From: "daniel.hartig" Date: Fri, 10 Jun 2022 18:49:53 -0500 Subject: [PATCH 2/4] Performed cargo fmt --- actix-session/src/session.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/actix-session/src/session.rs b/actix-session/src/session.rs index 87505bda19..5fc4e0a31b 100644 --- a/actix-session/src/session.rs +++ b/actix-session/src/session.rs @@ -75,20 +75,17 @@ struct SessionInner { } 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{ + let inner = SessionInner { state: HashMap::new(), status: SessionStatus::default(), }; Session(Rc::new(RefCell::new(inner))) } - - /// Get a `value` from the session. /// /// It returns an error if it fails to deserialize as `T` the JSON value associated with `key`. From be74a7c58cb4f95e0437838143f5196cf52dc724 Mon Sep 17 00:00:00 2001 From: "daniel.hartig" Date: Fri, 10 Jun 2022 18:51:48 -0500 Subject: [PATCH 3/4] Added to changelog --- actix-session/CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index cc0c8b10ce..014b053088 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -2,6 +2,9 @@ ## Unreleased - 2021-xx-xx +## Unreleased - 2022-06-09 + - Add an `empty()` function to `Session` for simple testing + ## 0.6.2 - 2022-03-25 - Implement `SessionExt` for `GuardContext`. [#234] From 60fc13b15e0daae5f5444c95fd56bd96a35873b3 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 19 Jul 2022 02:00:38 +0100 Subject: [PATCH 4/4] Update CHANGES.md --- actix-session/CHANGES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index a9b4ddfc64..9e833f8f09 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -1,9 +1,9 @@ # Changes -## Unreleased - 2021-xx-xx +## Unreleased - 2022-xx-xx + - Add an `empty()` function to `Session` for simple testing. [#253] -## Unreleased - 2022-06-09 - - Add an `empty()` function to `Session` for simple testing +[#253]: https://github.com/actix/actix-extras/pull/253 ## 0.7.0 - 2022-07-09