root/lang/perl/DBIx-Skinny/trunk/t/04_count.t @ 27239

Revision 27239, 0.7 kB (checked in by nekokak, 6 years ago)

add find_or_create and count.

Line 
1use strict;
2use warnings;
3use Test::Declare;
4use lib './t';
5use utf8;
6use Mock;
7
8plan tests => blocks;
9
10describe 'basic test' => run {
11    init {
12        Mock->setup_test_db;
13    };
14
15    test 'find_or_create' => run {
16        Mock->insert('tag',{
17            id   => 1,
18            name => 'perl',
19        });
20        my $row = Mock->count('tag' => {id => 'count'});
21        is $row->count, 1;
22
23        Mock->insert('tag',{
24            id   => 2,
25            name => 'ruby',
26        });
27        $row = Mock->count('tag' => {id => 'count'});
28        is $row->count, 2;
29
30        $row = Mock->count('tag' => {id => 'count'},{name => 'perl'});
31        is $row->count, 1;
32    };
33};
34
Note: See TracBrowser for help on using the browser.