API-Docker

 view release on metacpan or  search on metacpan

t/entity_roles.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use lib 't/lib';
use Test::API::Docker::Mock;
use API::Docker::Role::Entity::Config;
use API::Docker::Role::Entity::Image;
use API::Docker::Role::Entity::Network;
use API::Docker::Role::Entity::Plugin;
use API::Docker::Role::Entity::Secret;
use API::Docker::Role::Entity::Volume;

# karr k84, the six resources k79 step 6/7 still owed after containers:
# Image, Network, Volume, Plugin, Secret, Config. The convenience methods live
# in API::Docker::Role::Entity::<Resource> and are composed into the generated
# classes the daemon answers with. Nothing may be written into those classes
# by hand -- maint/spec-to-type.pl --verify compares them against the swagger
# byte for byte (t/spec_to_type.t) -- so this file is what proves the methods
# arrive anyway.
#
# t/entity_container.t is the same file for containers, and stays separate:
# containers have nineteen methods and two shapes that disagree in ways worth
# asserting one by one. This file carries the invariants all six share, and
# each resource's own forwarding assertions stay in its own test file
# (t/images.t, t/networks.t, t/volumes.t, t/plugins.t, t/secrets_configs.t).
#
# Fixture-only throughout: none of it needs a daemon, and the assertions are
# about the model rather than about anything an engine answers.

check_live_access();

# Which generated classes each role belongs on, and the field the role
# addresses the resource by. Written out rather than derived from the roles,
# so a class quietly dropping out of a composition loop is a failure here and
# not a shorter list compared against itself.
#
# Two of the six answer list and inspect with two different definitions;
# four answer both with one. Read off spec/v1.51.yaml, not assumed:
#   /images/json      -> [ImageSummary]   /images/{name}/json -> ImageInspect
#   /networks         -> [Network]        /networks/{id}      -> Network
#   /volumes          -> VolumeListResponse{Volumes: [Volume]}
#                                         /volumes/{name}     -> Volume
#   /plugins          -> [Plugin]         /plugins/{name}/json-> Plugin
#   /secrets          -> [Secret]         /secrets/{id}       -> Secret
#   /configs          -> [Config]         /configs/{id}       -> Config
my @RESOURCES = (
  { role    => 'API::Docker::Role::Entity::Image',
    classes => [qw( API::Docker::Type::ImageSummary
                    API::Docker::Type::ImageInspect )],
    key     => 'id',
    methods => [qw( history inspect remove tag )] },
  { role    => 'API::Docker::Role::Entity::Network',
    classes => ['API::Docker::Type::Network'],
    key     => 'id',
    methods => [qw( connect disconnect inspect remove )] },
  { role    => 'API::Docker::Role::Entity::Volume',
    classes => ['API::Docker::Type::Volume'],
    key     => 'name',
    methods => [qw( inspect remove )] },
  { role    => 'API::Docker::Role::Entity::Plugin',
    classes => ['API::Docker::Type::Plugin'],
    key     => 'name',
    methods => [qw( configure disable enable inspect push remove upgrade )] },
  { role    => 'API::Docker::Role::Entity::Secret',
    classes => ['API::Docker::Type::Secret'],



( run in 0.510 second using v1.01-cache-2.11-cpan-364913b4093 )