From bae1843f1a1d644fb3bd4f8c40b1dbb900aa3325 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Sun, 1 Aug 2021 14:51:28 +0200 Subject: Use guile parameters With parameters, the API does not need to care about the directory where to load files and how to get the time. --- tests/cache-valid.scm | 56 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'tests/cache-valid.scm') diff --git a/tests/cache-valid.scm b/tests/cache-valid.scm index cf5c0f1..04e7c22 100644 --- a/tests/cache-valid.scm +++ b/tests/cache-valid.scm @@ -16,6 +16,7 @@ (use-modules (webid-oidc cache) (webid-oidc testing) + ((webid-oidc parameters) #:prefix p:) (web uri) (web request) (web response) @@ -44,31 +45,42 @@ (last-modified . ,(time-utc->date (make-time time-utc 0 10))) (date . ,(time-utc->date (make-time time-utc 0 30)))))) ;; response-not-stored: never valid. - (when (valid? response-not-stored #:current-time 0) - (exit 1)) - (when (valid? response-not-stored #:current-time 100) - (exit 2)) + (parameterize ((p:current-date 0)) + (when (valid? response-not-stored) + (exit 1))) + (parameterize ((p:current-date 100)) + (when (valid? response-not-stored) + (exit 2))) ;; response-not-cached: never valid. - (when (valid? response-not-cached #:current-time 0) - (exit 3)) - (when (valid? response-not-cached #:current-time 100) - (exit 4)) + (parameterize ((p:current-date 0)) + (when (valid? response-not-cached) + (exit 3))) + (parameterize ((p:current-date 100)) + (when (valid? response-not-cached) + (exit 4))) ;; response-with-expires: valid at 110, invalid at 130. - (unless (valid? response-with-expires #:current-time 110) - (exit 5)) - (when (valid? response-with-expires #:current-time 130) - (exit 6)) + (parameterize ((p:current-date 110)) + (unless (valid? response-with-expires) + (exit 5))) + (parameterize ((p:current-date 130)) + (when (valid? response-with-expires) + (exit 6))) ;; response-with-overriden-expires: valid at 105, invalid at 115 - (unless (valid? response-with-overriden-expires #:current-time 105) - (exit 7)) - (when (valid? response-with-overriden-expires #:current-time 115) - (exit 8)) + (parameterize ((p:current-date 105)) + (unless (valid? response-with-overriden-expires) + (exit 7))) + (parameterize ((p:current-date 115)) + (when (valid? response-with-overriden-expires) + (exit 8))) ;; response-without-max-age: not valid, cannot get a heuristic - (when (valid? response-without-max-age #:current-time 10) - (exit 9)) + (parameterize ((p:current-date 10)) + (when (valid? response-without-max-age) + (exit 9))) ;; response-with-heuristic-max-age: the heuristic max age is 2, so ;; it is valid at 31 but not at 33. - (unless (valid? response-with-heuristic-max-age #:current-time 31) - (exit 10)) - (when (valid? response-with-heuristic-max-age #:current-time 33) - (exit 11)))) + (parameterize ((p:current-date 31)) + (unless (valid? response-with-heuristic-max-age) + (exit 10))) + (parameterize ((p:current-date 33)) + (when (valid? response-with-heuristic-max-age) + (exit 11))))) -- cgit v1.2.3