Improve unit test & Fix file extension (#2071)
This commit is contained in:
parent
d56a76584a
commit
944b0f1c5c
|
@ -35,8 +35,8 @@ has fileNameSeparator => ( is => 'rw', default => '_' );
|
|||
# If $ref is set, returns only notification corresponding to this reference.
|
||||
sub get {
|
||||
my ( $self, $uid, $ref ) = @_;
|
||||
my $ext = $self->extension;
|
||||
return () unless ($uid);
|
||||
my $ext = $self->extension;
|
||||
my $fns = $self->{fileNameSeparator};
|
||||
my $identifier = &getIdentifier( $self, $uid, $ref );
|
||||
|
||||
|
@ -61,11 +61,12 @@ sub get {
|
|||
sub getAccepted {
|
||||
my ( $self, $uid, $ref ) = @_;
|
||||
return () unless ($uid);
|
||||
my $ext = $self->extension;
|
||||
my $fns = $self->{fileNameSeparator};
|
||||
my $identifier = &getIdentifier( $self, $uid, $ref );
|
||||
|
||||
opendir D, $self->{dirName};
|
||||
my @notif = grep /^\d{8}${fns}${identifier}\S*\.(?:done|json)$/, readdir(D);
|
||||
my @notif = grep /^\d{8}${fns}${identifier}\S*\.(?:done|$ext)$/, readdir(D);
|
||||
closedir D;
|
||||
|
||||
my $files;
|
||||
|
|
|
@ -6,12 +6,12 @@ use JSON qw(from_json);
|
|||
require 't/test-lib.pm';
|
||||
|
||||
my $res;
|
||||
my $file = "$main::tmpDir/20160530_dwho_dGVzdHJlZg==.json";
|
||||
my $file = "$main::tmpDir/20160530_allusers_dGVzdHJlZg==.json";
|
||||
|
||||
open F, "> $file" or die($!);
|
||||
print F '[
|
||||
{
|
||||
"uid": "dwho",
|
||||
"uid": "allusers",
|
||||
"date": "2016-05-30",
|
||||
"reference": "testref",
|
||||
"title": "Test title",
|
||||
|
@ -104,8 +104,8 @@ ok(
|
|||
),
|
||||
"Accept notification"
|
||||
);
|
||||
$file =~ s/json$/done/;
|
||||
ok( -e $file, 'Notification was deleted' );
|
||||
|
||||
ok( -e $file, 'Notification was not deleted' );
|
||||
count(2);
|
||||
|
||||
$id = expectCookie($res);
|
||||
|
@ -216,8 +216,8 @@ ok(
|
|||
|
||||
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
|
||||
or print STDERR "$@\n" . Dumper($res);
|
||||
ok( $json->{error} eq 'Missing parameter', ' Missing parameter' )
|
||||
or explain( $json, "Missing parameter" );
|
||||
ok( $json->{error} eq 'Missing epoch parameter', ' Missing epoch parameter' )
|
||||
or explain( $json, "Missing epoch parameter" );
|
||||
count(3);
|
||||
|
||||
# Bad request
|
||||
|
|
Loading…
Reference in New Issue
Block a user