Config-Model-Itself
view release on metacpan or search on metacpan
t/load_write_itself.t view on Meta::CPAN
use ExtUtils::testlib;
use Test::More;
use Test::Differences;
use Config::Model 2.138;
use Config::Model::Tester::Setup qw/init_test setup_test_dir/;
use Data::Dumper ;
use Config::Model::Itself ;
use Text::Diff;
use Path::Tiny;
use File::Copy::Recursive qw(fcopy rcopy dircopy);
use warnings;
use strict;
use 5.10.1;
$File::Copy::Recursive::KeepMode = 0;
my ($meta_model, $trace) = init_test();
my $wr_test = setup_test_dir ;
# copy itself model
# avoid patching this file for Debian autopkgtest
my $orig_cm_dir = path($INC{'Config/Model/Itself.pm'})->parent;
my $orig_model_dir = $orig_cm_dir->child('models');
my $target_cm_dir = $wr_test->child('lib/Config/Model');
my $target_model_dir = $target_cm_dir->child('models');
note("Copying models from $orig_model_dir");
# start copy *below* models.
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809294
dircopy($orig_cm_dir->stringify, $target_cm_dir->stringify);
my @expected_classes =
qw/
Itself::Application Itself::CargoElement
Itself::Class Itself::CommonElement
Itself::CommonElement::Assert
Itself::CommonElement::Update
Itself::CommonElement::UpdateFiles
Itself::CommonElement::WarnIfMatch Itself::ComputedValue
Itself::ConfigAccept Itself::ConfigReadWrite
Itself::ConfigReadWrite::DefaultLayer Itself::Element
Itself::MigratedValue Itself::Model Itself::NonWarpableElement
Itself::WarpApply Itself::WarpOnlyElement Itself::WarpValue
Itself::WarpableElement
/;
my $ref_cds;
my @ref_elements;
subtest "Dog food Itself" => sub {
my $inst = $meta_model->instance (
root_class_name => 'Itself::Model',
instance_name => 'itself_instance',
root_dir => $wr_test,
);
ok($inst,"Read Itself::Model and created instance") ;
my $root = $inst -> config_root ;
my $rw_obj = Config::Model::Itself->new(
cm_lib_dir => $target_cm_dir->stringify,
model_object => $root
( run in 0.885 second using v1.01-cache-2.11-cpan-6aa56a78535 )