#!perl -T
use
5.006;
plan
tests
=> 11;
SKIP: {
or skip
'Failed to fetch volatile data; error is: '
. (
defined
$Test::GetVolatileData::ERROR
?
$Test::GetVolatileData::ERROR
:
'[undefined]'
), 1;
like(
$test
,
qr/test\d/
,
'get_data() without any extra args'
);
}
SKIP: {
num
=> 1,
) or skip
'Failed to fetch volatile data; error is: '
. (
defined
$Test::GetVolatileData::ERROR
?
$Test::GetVolatileData::ERROR
:
'[undefined]'
), 2;
is(
scalar
(
@test
),
1,
q{get_data('...', num => 1, returns two data pieces) }
,
);
is(
scalar
(
grep
/\Atest\d\z/,
@test
),
1,
q{get_data('...', num => 1, returns proper data pieces }
,
);
}
SKIP: {
num
=> 2,
) or skip
'Failed to fetch volatile data; error is: '
. (
defined
$Test::GetVolatileData::ERROR
?
$Test::GetVolatileData::ERROR
:
'[undefined]'
), 2;
is(
scalar
(
@test
),
2,
q{get_data('...', num => 2, returns two data pieces) }
,
);
is(
scalar
(
grep
/\Atest\d\z/,
@test
),
2,
q{get_data('...', num => 2, returns proper data pieces }
,
);
}
SKIP: {
num
=> 2000,
) or skip
'Failed to fetch volatile data; error is: '
. (
defined
$Test::GetVolatileData::ERROR
?
$Test::GetVolatileData::ERROR
:
'[undefined]'
), 2;
is(
scalar
(
@test
),
5,
q{get_data('...', num => OVERLY_LARGE, returns all data pieces) }
,
);
is(
scalar
(
grep
/\Atest\d\z/,
@test
),
5,
q{get_data('...', num => OVERLY_LARGE, returns proper data pieces }
,
);
}
is(
$must_be_undef
,
undef
,
'Errored out return must be undef'
);
diag
'[Must get this error] Error is '
. (
defined
$Test::GetVolatileData::ERROR
?
$Test::GetVolatileData::ERROR
:
'[undefined]'
);
like(
$Test::GetVolatileData::ERROR
,
qr/Network error/
,
'errored out return must set ::ERROR'
,
);
diag
'[Must get this error] Error is '
. (
defined
$Test::GetVolatileData::ERROR
?
$Test::GetVolatileData::ERROR
:
'[undefined]'
);
is(
$must_be_undef2
,
undef
,
'Errored out return must be undef'
);
like(
$Test::GetVolatileData::ERROR
,
qr/Network error/
,
'errored out return must set ::ERROR (when ``num`` is set)'
,
);