Improve unit tests & update version (#1853)
This commit is contained in:
parent
f515819c61
commit
27116ca1af
|
@ -4,7 +4,7 @@ use strict;
|
|||
use Mouse;
|
||||
use XML::LibXML;
|
||||
|
||||
our $VERSION = '2.0.0';
|
||||
our $VERSION = '2.0.6';
|
||||
|
||||
# XML parser
|
||||
has parser => (
|
||||
|
|
|
@ -16,6 +16,14 @@ my $json = '{
|
|||
"text": "This is a test text"
|
||||
}';
|
||||
|
||||
my $json2 = '{
|
||||
"date": "2016-05-31",
|
||||
"reference": "testref",
|
||||
"uid": "dwho",
|
||||
"title": "Test2 title",
|
||||
"text": "This is a second test text"
|
||||
}';
|
||||
|
||||
my $client = LLNG::Manager::Test->new( {
|
||||
ini => {
|
||||
logLevel => 'error',
|
||||
|
@ -41,6 +49,21 @@ ok(
|
|||
);
|
||||
count(1);
|
||||
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
'/notifications', IO::String->new($json2),
|
||||
type => 'application/json',
|
||||
length => length($json2)
|
||||
),
|
||||
'Try to create the same notification twice'
|
||||
);
|
||||
ok(
|
||||
$res->[2]->[0] =~
|
||||
/"error"\s*:\s*"A notification already exists with reference testref"/,
|
||||
'Append the same notification is refused'
|
||||
);
|
||||
count(2);
|
||||
|
||||
# Try to authenticate
|
||||
# -------------------
|
||||
ok(
|
||||
|
|
|
@ -9,7 +9,7 @@ BEGIN {
|
|||
require 't/test-lib.pm';
|
||||
}
|
||||
|
||||
my $maintests = 3;
|
||||
my $maintests = 4;
|
||||
my $debug = 'error';
|
||||
my $client;
|
||||
|
||||
|
@ -52,6 +52,13 @@ my $xml = '<?xml version="1.0" encoding="UTF-8"?>
|
|||
<text>This is a test text</text>
|
||||
</notification></root>';
|
||||
|
||||
my $xml2 = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root><notification uid="dwho" date="2016-05-31" reference="testref">
|
||||
<title>Test title</title>
|
||||
<subtitle>Test subtitle</subtitle>
|
||||
<text>This is a test text</text>
|
||||
</notification></root>';
|
||||
|
||||
SKIP: {
|
||||
eval "use SOAP::Lite; use XML::LibXML; use XML::LibXSLT;";
|
||||
if ($@) {
|
||||
|
@ -79,8 +86,15 @@ SKIP: {
|
|||
'SOAP client'
|
||||
);
|
||||
$soap->default_ns('urn:Lemonldap/NG/Common/PSGI/SOAPService');
|
||||
ok( $soap->call( 'newNotification', $xml )->result() == 1,
|
||||
' SOAP call returns 1' );
|
||||
ok(
|
||||
$soap->call( 'newNotification', $xml )->result() == 1,
|
||||
' Append a notification -> SOAP call returns 1'
|
||||
);
|
||||
$soap->default_ns('urn:Lemonldap/NG/Common/PSGI/SOAPService');
|
||||
ok(
|
||||
$soap->call( 'newNotification', $xml2 )->result() == 0,
|
||||
' Append the same notification twice -> SOAP call returns 0'
|
||||
);
|
||||
|
||||
# Try to authenticate
|
||||
# -------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user