Commit | Line | Data |
db29433c |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use Time::HiRes qw/gettimeofday/; |
5 | |
6 | use lib qw(t/lib); |
7 | use DBICTest; # do not remove even though it is not used |
8 | |
9 | our $src_count = 100; |
10 | |
11 | for (1 .. $src_count) { |
12 | eval <<EOM or die $@; |
13 | |
14 | package DBICTest::NS::Stress::Schema::Result::T$_; |
15 | use base qw/DBIx::Class::Core/; |
16 | __PACKAGE__->table($_); |
17 | __PACKAGE__->add_columns ( |
18 | id => { data_type => 'integer', is_auto_increment => 1 }, |
19 | data => { data_type => 'varchar', size => 255 }, |
20 | ); |
21 | __PACKAGE__->set_primary_key('id'); |
22 | __PACKAGE__->add_unique_constraint(['data']); |
23 | |
24 | EOM |
25 | } |
26 | |
27 | { |
28 | package DBICTest::NS::Stress::Schema; |
29 | |
30 | use base qw/DBIx::Class::Schema/; |
31 | |
32 | sub _findallmod { |
33 | return $_[1] eq ( __PACKAGE__ . '::Result' ) |
34 | ? ( map { __PACKAGE__ . "::Result::T$_" } 1 .. $::src_count ) |
35 | : () |
36 | ; |
37 | } |
38 | } |
39 | |
40 | is (DBICTest::NS::Stress::Schema->sources, 0, 'Start with no sources'); |
41 | |
42 | |
43 | note gettimeofday . ":\tload_namespaces start"; |
44 | DBICTest::NS::Stress::Schema->load_namespaces; |
45 | note gettimeofday . ":\tload_namespaces finished"; |
46 | |
47 | is (DBICTest::NS::Stress::Schema->sources, $src_count, 'All sources attached'); |
48 | |
49 | done_testing; |