1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
# vi:filetype=
use lib 'lib';
use Test::Nginx::Socket;
use POSIX qw(strftime);
my $fmt="%a %b %e %H:%M:%S %Y";
our $str_local = (strftime $fmt, localtime time()).'|'.(strftime $fmt, localtime time()+1).'|'.(strftime $fmt, localtime time()+2);
our $str_gmt = (strftime $fmt, gmtime time()).'|'.(strftime $fmt, gmtime time()+1).'|'.(strftime $fmt, gmtime time()+2);
repeat_each(2);
plan tests => repeat_each() * 2 * blocks();
log_level('warn');
run_tests();
#no_diff();
__DATA__
=== TEST 1: local time format
--- config
location /foo {
set_formatted_local_time $today "%a %b %e %H:%M:%S %Y";
echo $today;
}
--- request
GET /foo
--- response_body_like eval: $main::str_local
=== TEST 2: GMT time format
--- config
location /bar {
set_formatted_gmt_time $today "%a %b %e %H:%M:%S %Y";
echo $today;
}
--- request
GET /bar
--- response_body_like eval: $main::str_gmt
=== TEST 3: set_formatted_gmt_time (empty formatter)
--- config
location /bar {
set_formatted_gmt_time $today "";
echo "[$today]";
}
--- request
GET /bar
--- response_body
[]
=== TEST 4: set_formatted_local_time (empty formatter)
--- config
location /bar {
set_formatted_local_time $today "";
echo "[$today]";
}
--- request
GET /bar
--- response_body
[]
=== TEST 5: set_formatted_local_time (constant formatter)
--- config
location /bar {
set_formatted_local_time $today "hello world";
echo "[$today]";
}
--- request
GET /bar
--- response_body
[hello world]
|