From a3b212b82b58e5971c70a1ad91fd2f3d775bddb5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 16 Jun 2023 15:07:29 +0300 Subject: [PATCH] test(tvix/serde): add a test for from_str_with_config Change-Id: I451851f4e01cb6dd0005e55bb852823b618f2ee6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8809 Autosubmit: tazjin Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/serde/src/de_tests.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tvix/serde/src/de_tests.rs b/tvix/serde/src/de_tests.rs index 8fe15a17e..50a078cc0 100644 --- a/tvix/serde/src/de_tests.rs +++ b/tvix/serde/src/de_tests.rs @@ -1,7 +1,7 @@ use serde::Deserialize; use std::collections::HashMap; -use crate::de::from_str; +use crate::de::{from_str, from_str_with_config}; #[test] fn deserialize_none() { @@ -198,3 +198,14 @@ fn deserialize_enum_all() { assert_eq!(result, expected); } + +#[test] +fn deserialize_with_config() { + let result: String = from_str_with_config("builtins.testWithConfig", |eval| { + // Add a literal string builtin that just returns `"ok"`. + eval.src_builtins.push(("testWithConfig", "\"ok\"")); + }) + .expect("should deserialize"); + + assert_eq!(result, "ok"); +}