File: 05response.t

package info (click to toggle)
libnet-akamai-perl 0.15-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 204 kB
  • ctags: 160
  • sloc: perl: 2,317; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,200 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -w
use strict;
use warnings;

use Test::More;

use Net::Akamai::ResponseData;

my @test_cases = (
    [[ 101, 'this is ok' ], [ '101 SUCCESSFUL: this is ok', 1, 0, 1]],
    [[ 200, 'a warn!' ],    [ '200 WARNING: a warn!', 0, 1, 1 ]],
    [[ 333, 'is bad ya' ],  [ '333 REJECTED: is bad ya', 0, 0, 0 ]],
    [[ 421, 'unkown' ],     [ '421 REJECTED: unkown', 0, 0, 0 ]],
);

foreach my $case (@test_cases) {
    my ($input, $output) = @$case;

    my ($result_code, $result_msg) = @$input;
    my $response = Net::Akamai::ResponseData->new(
        result_code => $result_code,
        result_msg  => $result_msg,
    );

    my ($message, $is_successful, $is_warning, $is_accepted) = @$output;
    is( $response->message(), $message, 'message is correct: ' . $message );

    is( "$response", $message, 'stringification worked' );

    ok( ($is_successful ? $response->successful() : !$response->successful()), 'check successful: ' . $is_successful );
    ok( ($is_warning ? $response->warning() : !$response->warning()), 'check warning: ' . $is_warning );
    ok( ($is_accepted ? $response->accepted() : !$response->accepted()), 'check accepted: ' . $is_accepted );
}

done_testing;