1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00
This commit is contained in:
Farid Zakaria 2025-11-07 10:04:46 +11:00 committed by GitHub
commit 66ff5c0f7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -513,4 +513,22 @@ TEST_F(nix_api_expr_test, nix_expr_attrset_update)
assert_ctx_ok();
}
/**
* @brief Validates the fix for https://github.com/NixOS/nix/issues/11972
*/
TEST_F(nix_api_expr_test, fromTOML_invalid_syntax_should_error_gracefully)
{
const char * expr = "builtins.fromTOML ''0000000000000000000000000000000000000'0''";
int status = nix_expr_eval_from_string(ctx, state, expr, ".", value);
ASSERT_NE(0, status) << "Evaluation should have failed but returned a success code.";
ASSERT_EQ(nix_err_code(ctx), NIX_ERR_NIX_ERROR)
<< "Expected a generic Nix error, but a different error code was set.";
ASSERT_THAT(nix_err_msg(nullptr, ctx, nullptr), ::testing::HasSubstr("invalid key value separator"))
<< "The error message should indicate a TOML parsing issue.";
}
} // namespace nixC