package MyApp::Test::Database::Live; use strict; use warnings; use MyAppDB; use MyApp::Model::MyAppDB; use Directory::Scratch; use YAML qw( DumpFile ); use FindBin qw( $Bin ); use Digest::SHA1 qw( sha1_hex ); use Catalyst::Test "MyApp"; use HTTP::Request; use base 'Exporter'; our @EXPORT = qw /schema log_in /; my $schema; my $config; BEGIN { my $tmp = Directory::Scratch->new; my $db = $tmp->touch('db'); my $dsn = "DBI:SQLite:$db"; $schema = MyAppDB->connect($dsn); $schema->deploy; $config = "$Bin/../myapp_Local.yml"; DumpFile($config, { 'MyApp::Model::MyAppDB' => { connect_info => [$dsn]}}); } sub schema { $schema }; sub log_in { my $mech = shift; my $dummy = { 'Content-type' => 'application/json' }; my $person = schema()->resultset('MyAppDB::User')->create({ login => 'testuser', password => sha1_hex('testing'), mail => 'testuser@mydomain.de', first_name => 'Max', last_name => 'Mustermann', company => 'MyCompany', customer_id => 'custid', }); my @ar; push @ar, $dummy; my $req = HTTP::Request->new('POST', 'http://localhost/rest/login/login', \@ar, '{ "login": "testuser", "password": "testing"}'. "\n" ); request($req); } END { unlink $config }; 1;