Metabase-Fact
view release on metacpan or search on metacpan
t/user/profile.t view on Meta::CPAN
);
}
return 1;
}
#--------------------------------------------------------------------------#
# start testing
#--------------------------------------------------------------------------#
require_ok('Metabase::User::Profile');
require_ok('Metabase::User::Secret');
#--------------------------------------------------------------------------#
# new profile creation
#--------------------------------------------------------------------------#
my $profile;
is exception {
$profile = Metabase::User::Profile->create(
full_name => "J\x{022f}hn Doe",
email_address => 'jdoe@example.com',
);
}, undef,
"create new profile";
isa_ok( $profile, 'Metabase::User::Profile' );
#--------------------------------------------------------------------------#
# save and load profiles
#--------------------------------------------------------------------------#
my $tempdir = File::Temp::tempdir( CLEANUP => 1 );
my $profile_file = File::Spec->catfile( $tempdir, 'profile.json' );
$profile->save($profile_file);
ok( -r $profile_file, 'profile saved to file' );
my $profile_copy = Metabase::User::Profile->load($profile_file);
ok( $profile_copy, "Loaded profile file (created with ->create)" );
isa_ok( $profile_copy, 'Metabase::User::Profile' );
_compare( $profile, $profile_copy );
# try profile-generator
my $bin = File::Spec->rel2abs( File::Spec->catfile(qw/bin metabase-profile/) );
my $cwd = Cwd::cwd();
chdir $tempdir;
END { chdir $cwd }
my $output_file = 'my.profile.json';
my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
$bin = $bin =~ m/\s/ ? qq{"$bin"} : $bin;
qx/$X $bin -o $output_file --name "JohnPublic" --email jp\@example.com --secret 3.14159/;
ok( -r $output_file, 'created named profile file with metabase-profile' );
qx/$X $bin --name "JohnPublic" --email jp\@example.com --secret 3.14159/;
ok( -r 'metabase_id.json', 'created default profile file with metabase-profile' );
my $file_guts = do { local ( @ARGV, $/ ) = 'metabase_id.json'; <> };
my $facts = $json->decode($file_guts);
my $profile_copy2 = Metabase::User::Profile->from_struct( $facts->[0] );
ok( $profile_copy2, "Loaded profile from file" );
my $secret_copy2 = Metabase::User::Secret->from_struct( $facts->[1] );
ok( $secret_copy2, "Loaded secret from file" );
done_testing;
( run in 1.770 second using v1.01-cache-2.11-cpan-6de40a662fe )