diff --git a/integration/hurl/tests_ok/function.hurl b/integration/hurl/tests_ok/function.hurl index ca0d9fe5dde..c0603bc9dad 100644 --- a/integration/hurl/tests_ok/function.hurl +++ b/integration/hurl/tests_ok/function.hurl @@ -1,4 +1,5 @@ GET http://localhost:8000/function [Query] uuid: {{newUuid}} +now: {{newDate}} HTTP 200 diff --git a/integration/hurl/tests_ok/function.py b/integration/hurl/tests_ok/function.py index 46a326e5bae..93fe4465a21 100644 --- a/integration/hurl/tests_ok/function.py +++ b/integration/hurl/tests_ok/function.py @@ -8,4 +8,8 @@ def function(): uuid_pattern = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" assert re.match(uuid_pattern, request.args.get("uuid")) + + date_pattern = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{9}" + assert re.match(date_pattern, request.args.get("now")) + return "" diff --git a/integration/hurlfmt/tests_export/function.html b/integration/hurlfmt/tests_export/function.html index edfabfa2f01..d6624333f98 100644 --- a/integration/hurlfmt/tests_export/function.html +++ b/integration/hurlfmt/tests_export/function.html @@ -1,4 +1,5 @@
GET http://localhost:8000/hello
[Query]
uuid: {{newUuid}}
+now: {{newDate}}
diff --git a/integration/hurlfmt/tests_export/function.hurl b/integration/hurlfmt/tests_export/function.hurl
index 8b4b8f11b59..83026bd4599 100644
--- a/integration/hurlfmt/tests_export/function.hurl
+++ b/integration/hurlfmt/tests_export/function.hurl
@@ -1,3 +1,4 @@
GET http://localhost:8000/hello
[Query]
uuid: {{newUuid}}
+now: {{newDate}}
diff --git a/integration/hurlfmt/tests_export/function.json b/integration/hurlfmt/tests_export/function.json
index 3e78810f2c8..a371fd136e0 100644
--- a/integration/hurlfmt/tests_export/function.json
+++ b/integration/hurlfmt/tests_export/function.json
@@ -1 +1 @@
-{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello","query_string_params":[{"name":"uuid","value":"{{newUuid}}"}]}}]}
+{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello","query_string_params":[{"name":"uuid","value":"{{newUuid}}"},{"name":"now","value":"{{newDate}}"}]}}]}
diff --git a/integration/hurlfmt/tests_export/function.lint.hurl b/integration/hurlfmt/tests_export/function.lint.hurl
index 8b4b8f11b59..83026bd4599 100644
--- a/integration/hurlfmt/tests_export/function.lint.hurl
+++ b/integration/hurlfmt/tests_export/function.lint.hurl
@@ -1,3 +1,4 @@
GET http://localhost:8000/hello
[Query]
uuid: {{newUuid}}
+now: {{newDate}}
diff --git a/packages/hurl/src/runner/function.rs b/packages/hurl/src/runner/function.rs
index f08acdbf701..7a32d7c4d87 100644
--- a/packages/hurl/src/runner/function.rs
+++ b/packages/hurl/src/runner/function.rs
@@ -1,3 +1,4 @@
+use chrono::Utc;
/*
* Hurl (https://hurl.dev)
* Copyright (C) 2024 Orange
@@ -24,6 +25,10 @@ use crate::runner::value::Value;
/// Evaluates the function `function`, returns a [`Value`] on success or an [`RunnerError`] .
pub fn eval(function: &Function) -> Result