CloudFlare-Client

 view release on metacpan or  search on metacpan

lib/CloudFlare/Client.pm  view on Meta::CPAN


use CloudFlare::Client::Exception::Connection;
use CloudFlare::Client::Exception::Upstream;
use LWP::UserAgent 6.02;
# This isn't used directly but we want the dependency
use LWP::Protocol::https 6.02;
use JSON::MaybeXS;

our $VERSION = 'v0.55.4'; # VERSION

# CF credentials
has '_user' => (
    is       => 'ro',
    isa      => Str,
    required => 1,
    init_arg => 'user',);
has '_key' => (
    is       => 'ro',
    isa      => Str,
    required => 1,
    init_arg => 'apikey',);

t/01-main.t  view on Meta::CPAN

# Moose tests
Readonly my $CLASS => 'CloudFlare::Client';
meta_ok($CLASS);
for my $attr (qw/ _user _key _ua/) {
    has_attribute_ok( $CLASS, $attr)}
lives_and { meta_ok( $CLASS->new( user => $USER, apikey => $KEY))}
          "Instance has meta";

# Construction
lives_and { new_ok($CLASS, [ user => $USER, apikey  => $KEY])}
          "construction with valid credentials works";
# Work around Moose versions
if($Moose::VERSION >= 2.1101) {
    # Missing user
    Readonly my $MISS_ARG_E => 'Moose::Exception::AttributeIsRequired';
    throws_ok { $CLASS->new( apikey => $KEY) } $MISS_ARG_E,
              "construction with missing user attribute throws exception";
    # Missing apikey
    throws_ok { $CLASS->new( user => $USER) } $MISS_ARG_E,
              "construction with missing apikey attribute throws exception";
    # Extra attr



( run in 0.249 second using v1.01-cache-2.11-cpan-4d50c553e7e )