From d37e5784eb8061b1fe50188fb50ef80d75f9f3ac Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 08:18:39 +0000 Subject: [PATCH] test(stdlib): add unit tests for redis module registration Adds test block to `stdlib/src/redis.rs` to ensure proper registration of the Redis module in `StdlibRegistry` and checks that the exported `connect` function correctly returns the expected string. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/redis.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/stdlib/src/redis.rs b/stdlib/src/redis.rs index 8be06367..d1651b5e 100644 --- a/stdlib/src/redis.rs +++ b/stdlib/src/redis.rs @@ -30,3 +30,39 @@ impl StdlibRegistry { ); } } + +#[cfg(test)] +mod tests { + use super::*; + use techscript_runtime::RuntimeContext; + + #[test] + fn test_register_redis() { + let mut registry = StdlibRegistry::default(); + registry.register_redis(); + + let module = registry + .modules + .get("std.redis") + .expect("Module std.redis should be registered"); + assert_eq!(module.name, "std.redis"); + assert_eq!(module.version, "1.0.0"); + + let connect_fn = module + .exports + .get("connect") + .expect("connect function should be exported"); + assert_eq!(connect_fn.arity(), 1); + + let mut ctx = RuntimeContext::new(techscript_runtime::RuntimeConfig::default()); + let args = vec![RuntimeValue::Str("localhost:6379".to_string())]; + let result = connect_fn + .call(&mut ctx, args) + .expect("connect function should succeed"); + + assert_eq!( + result, + RuntimeValue::Str("Redis not yet available".to_string()) + ); + } +}