1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5
6use File::Spec;
7use File::Temp;
8
9use Test::More;
10
11use Try::Tiny;
12
13# Start at 1 since $test_count++ in BEGIN() does not work :-).
14
15our $test_count = 1;
16
17# -----------------------------------------------
18
19sub BEGIN { use_ok('DBIx::Admin::DSNManager'); }
20
21# -----------------------------------------------
22
23my($dsn)       = 'dbi:Pg:dbname=prod';
24my($attr)      = {AutoCommit => 1, PrintError => 1, RaiseError => 1};
25my($file_name) = File::Spec -> catdir('t', 'dsn.ini');
26my($section)   = 'Pg.2';
27my($use_it)    = 1;
28
29try
30{
31	my($manager)   = DBIx::Admin::DSNManager -> new
32	(
33		file_name => $file_name,
34		verbose   => 1,
35	);
36
37	isa_ok($manager, 'DBIx::Admin::DSNManager', 'Class of object');
38
39	$test_count++;
40
41	my($config) = $manager -> config;
42
43	ok($$config{$section}{dsn} eq $dsn, 'Recovered dsn from file');
44
45	$test_count++;
46
47	is_deeply($$config{$section}{attributes}, $attr, 'Recovered attributes hashref from file');
48
49	$test_count++;
50
51	ok($$config{$section}{use_for_testing} eq $use_it, 'Recovered use_for_testing from file');
52
53	$test_count++;
54}
55catch
56{
57	BAIL_OUT($_);
58};
59
60done_testing($test_count);
61