user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
* [PATCH] t/psgi_search: fix test around date boundaries
@ 2021-02-15  2:36 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-02-15  2:36 UTC (permalink / raw)
  To: meta

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" ],

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-15  2:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15  2:36 [PATCH] t/psgi_search: fix test around date boundaries Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git