chizmw / test-dbix-class-schema

DBIx::Class schema sanity checking tests
http://search.cpan.org/dist/Test-DBIx-Class-Schema/
3 stars 6 forks source link

Test::DBIx::Class::Schema 1.0.2 test#3 not ok with 'Result' in name #8

Closed chizmw closed 1 year ago

chizmw commented 11 years ago

(submitted by email)

When attempting to use this Test::DBIx::Class::Scheme version 1.0.2 , I had problems getting test3 to pass: (I'm on a debian squeeze and also archlinux, and am installing cpanm (carton install) local::lib

If my schema is Koha::Schema and had been generated with dbicdump so that I would have: Koha::Schema::Result::City test #3 would never match.

not ok 3 - The record object is a ::City
#   Failed test 'The record object is a ::City'
#   at local/lib/perl5/Test/DBIx/Class/Schema.pm line 76.
#                   'Koha::Schema::Result::City'
#     doesn't match '(?^:Koha(?:::Schema)?::City)'

Of course if I added glue => 'Result' that was sufficient to make it pass, but I am not sure if this is the intended API (i.e. not in POD or docs).

In local/lib/perl5/Test/DBIx/Class/Schema.pm my $expected_type_re = $self->{namespace} . '::' . $self->{moniker}; could be changed to: my $expected_type_re = $self->{namespace} . '::Result' . $self->{moniker}; but I don't know if thats semantically correct for $record.

Maybe I am doing something wrong. Or maybe I need to use the 'glue', or maybe it might be worth an adjustment to the matching code to deal with 'Result'.

As you can see I am trying to introduce DBIx to a legacy project.

Thank you for your efforts.

Signed, wajasu

My test:

#!/usr/bin/perl

use strict;
use warnings;

use Test::DBIx::Class::Schema;

my $schematest = Test::DBIx::Class::Schema->new({
    # required
    dsn        => 'DBI:mysql:database=koha;host=192.168.122.87',
    namespace  => 'Koha::Schema',
    moniker    => 'City',
    glue       => 'Result',     # without this it fails test #3
    #optional
    username   => 'koha',
    password   => 'koha',
});

$schematest->methods({
    columns    => [ qw[ cityid city_name city_state city_country city_zipcode ] ],
    custom     => [ qw[ cityid city_name city_state city_country city_zipcode ] ],
    relations  => [ qw[ ] ],
    resultsets => [ qw[ ] ],
});

$schematest->run_tests();
chizmw commented 11 years ago

Is this resolved with the doc-fix in pull/issue #9?