File: 05-output-bool.t

package info (click to toggle)
libdbix-runsql-perl 0.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 248 kB
  • sloc: perl: 825; sql: 26; makefile: 10
file content (39 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!perl -w
use strict;
use Test::More;

use DBIx::RunSQL;
use Data::Dumper;

# Test against a "real" database if we have one:
if( ! eval { require DBD::SQLite;
             require 5.008; # for scalar open
             1;  }) {
    plan skip_all => $@;
    exit;
};

plan tests => 1;

# Redirect STDOUT to a variable
close STDOUT; # shhh
open STDOUT, '>', \my $output;

my $exitcode = DBIx::RunSQL->handle_command_line(
    "my-test-app",
    [
    '--bool',
    '--dsn' => 'dbi:SQLite:dbname=:memory:',
    '--sql' => <<'SQL',
        create table foo (bar integer, baz varchar);
        insert into foo (bar,baz) values (1,'hello');
        insert into foo (bar,baz) values (2,'world');
        select * from foo;
SQL
    ]
);

is $exitcode, 1, "We get a nonzero exit code if a row gets selected with --bool"
    or diag $output;

done_testing();