user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] t/psgi_search: fix test around date boundaries
Date: Mon, 15 Feb 2021 02:36:38 +0000	[thread overview]
Message-ID: <20210215023638.20135-1-e@80x24.org> (raw)

git approxidate won't actually return times in the future,
so "1.{hour,day,year}.from.now" all return the current epoch
time.

So just use "now" and ensure we have a predictable time zone for
testing.
---
 t/psgi_search.t | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/t/psgi_search.t b/t/psgi_search.t
index 514df005..9facdf3d 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -17,6 +17,7 @@ use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
 use_ok 'PublicInbox::WWW';
 use_ok 'PublicInbox::SearchIdx';
 my ($tmpdir, $for_destroy) = tmpdir();
+local $ENV{TZ} = 'UTC';
 
 my $ibx = PublicInbox::Inbox->new({
 	inboxdir => $tmpdir,
@@ -75,7 +76,7 @@ my $www = PublicInbox::WWW->new($cfg);
 test_psgi(sub { $www->call(@_) }, sub {
 	my ($cb) = @_;
 	my ($html, $res);
-	my $approxidate = '1.hour.from.now';
+	my $approxidate = 'now';
 	for my $req ('/test/?q=%C3%86var', '/test/?q=%25C3%2586var') {
 		$res = $cb->(GET($req."+d:..$approxidate"));
 		$html = $res->content;
@@ -135,7 +136,7 @@ test_psgi(sub { $www->call(@_) }, sub {
 		qr/filename=no-subject\.mbox\.gz/);
 
 	# "full threads" mbox.gz download
-	$res = $cb->(POST('/test/?q=s:test+d:..1.hour.from.now&x=m&t'));
+	$res = $cb->(POST("/test/?q=s:test+d:..$approxidate&x=m&t"));
 	is($res->code, 200, 'successful mbox download with threads');
 	gunzip(\($res->content) => \(my $before));
 	is_deeply([ "Message-ID: <$mid>\n", "Message-ID: <reply\@asdf>\n" ],

                 reply	other threads:[~2021-02-15  2:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210215023638.20135-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH] t/psgi_search: fix test around date boundaries' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).