]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/psgi_search: fix test around date boundaries
authorEric Wong <e@80x24.org>
Mon, 15 Feb 2021 02:36:38 +0000 (02:36 +0000)
committerEric Wong <e@80x24.org>
Mon, 15 Feb 2021 14:47:14 +0000 (08:47 -0600)
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

index 514df0050068e80f61a8775dc360f9c37c1fda19..9facdf3d13f25b7c76d39996d34431bae6339185 100644 (file)
@@ -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" ],