Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users
myapp_local.yml gets ignored
 

Index | Next | Previous | View Flat


jochen.luig at skytel

Jun 17, 2009, 6:50 AM


Views: 686
Permalink
myapp_local.yml gets ignored

Hi,

I'm currently writing tests for an application. To be able to test with
a live database, I wrote a test database package along the lines of the
example in chapter 8 (page 165) of Johnathan's Catalyst book:

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 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]}});
DumpFile('/home/jochen/location.txt', { 'path' => $config });
}

sub schema { $schema };

sub log_in {
my $mech = shift;

my $obj = '{ "login": "testuser", "password": "testing"}' . "\n";
my $dummy = [ 'Content-type' => 'application/json', 'Content-Length'
=> length($obj) ];
my $user = schema()->resultset('MyAppDB::User')->create({
login => 'testuser',
password => sha1_hex('testing'),
#password => 'testing',
mail => 'testuser[at]mydomain.com',
first_name => 'Max',
last_name => 'Mustermann',
company => 'mycompany',
customer_id => '002096',
});
my $req = HTTP::Request->new('POST',
'http://localhost/rest/login/login', $dummy, $obj);
$mech->request($req);
return $user;
}

END { unlink $config };

1;

When the login request failed, I first thought it had to do with the
authentication process. But when there was a change in the db schema
that I hadn't made accordingly in my local mysql database, the test
script complained about the columns not present in the database. So the
myapp_local.yml seems to get ignored. OTOH, the test user is not created
in that database.
According to the ConfigLoader docs, 'local' is the default suffix for
files used to override the main config, so AFAIU the above code is
supposed to "just work".
Maybe I'm just not seeing the wood for the trees here, but are there any
prerequisites for this to work that I may have overlooked?

Jochen


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Subject User Time
myapp_local.yml gets ignored jochen.luig at skytel Jun 17, 2009, 6:50 AM
    Re: myapp_local.yml gets ignored ben-catalyst at vinnerd Jun 17, 2009, 7:58 AM
        RE: myapp_local.yml gets ignored c.a.vincent at newcastle Jun 17, 2009, 8:13 AM
    Re: myapp_local.yml gets ignored ben-catalyst at vinnerd Jun 17, 2009, 8:20 AM
    RE: myapp_local.yml gets ignored jochen.luig at skytel Jun 17, 2009, 8:28 AM
    Re: myapp_local.yml gets ignored bobtfish at bobtfish Jun 18, 2009, 12:50 AM
        Re: myapp_local.yml gets ignored jochen.luig at skytel Jun 19, 2009, 12:27 AM
    Re: myapp_local.yml gets ignored ben-catalyst at vinnerd Jun 18, 2009, 7:27 AM
        Re: myapp_local.yml gets ignored jochen.luig at skytel Jun 19, 2009, 12:20 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.