Mercurial > crates > nonstick
diff testharness/src/lib.rs @ 172:6727cbe56f4a
Test environment variable setting; minor cleanup.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Fri, 25 Jul 2025 21:02:53 -0400 |
parents | e27c5c667a5a |
children | 46e8ce5cd5d1 |
line wrap: on
line diff
--- a/testharness/src/lib.rs Fri Jul 25 20:52:14 2025 -0400 +++ b/testharness/src/lib.rs Fri Jul 25 21:02:53 2025 -0400 @@ -1,6 +1,7 @@ //! The nonstick library use crate::nonstick::items::ItemsMut; +use crate::nonstick::EnvironMapMut; use std::cell::Cell; extern crate nonstick; @@ -55,12 +56,14 @@ } fn account_management(handle: &mut M, _: Vec<&CStr>, _: AuthnFlags) -> nonstick::Result<()> { - let value: &Cell<i32> = match handle.username(None)?.as_bytes() { + match handle.username(None)?.as_bytes() { b"initial" => return Err(ErrorCode::AccountExpired), - b"updated-in-process" => handle.get_module_data("florgus"), + b"updated-in-process" => (), _ => return Err(ErrorCode::UserUnknown), - } - .ok_or(ErrorCode::SessionError)?; + }; + let value: &Cell<i32> = handle + .get_module_data("florgus") + .ok_or(ErrorCode::SessionError)?; let florgus_str: Option<&i32> = handle.get_module_data("florgus"); if let Some(s) = florgus_str { error!( @@ -72,6 +75,7 @@ error!(handle, "wrong value! {}", value.get()); return Err(ErrorCode::AuthTokError); } + handle.environ_mut().insert("nin", "nine inch nails"); let password = handle.authtok(None)?; if password.as_bytes() == b"valid" { Err(ErrorCode::NewAuthTokRequired)