Apache-Voodoo

 view release on metacpan or  search on metacpan

t/Table.t  view on Meta::CPAN

use strict;
use warnings;

use Data::Dumper;
use Test::More tests => 17;

use_ok('File::Temp');
use_ok('DBI');
use_ok('Apache::Voodoo::Exception');
use_ok('Apache::Voodoo::Table');
use_ok('Apache::Voodoo::Table::Probe');

################################################################################
# Tests related to checking the config syntax
################################################################################
my $table;
eval {
	$table = Apache::Voodoo::Table->new({ });
};
my $e = Exception::Class->caught();
isa_ok($e,"Apache::Voodoo::Exception::RunTime::BadConfig");

eval {
	$table = Apache::Voodoo::Table->new({
		table       => '_vtable',
		columns => {
			id => {	
				type => 'unsigned_int',
				bytes => 4
			}
		}
	});
};

my $avt_table_config = {
	table => 'avt_table',
	primary_key => 'id',
	columns => {
		id     => { type => 'unsigned_int', bytes => 4, required => 1 },
		avt_ref_table_id => { 
			type => 'unsigned_int', 
			bytes => 4, 
			required => 1,
			references => {
				table => 'avt_ref_table',
				primary_key => 'id',
				columns => ['name'],
				select_label => 'name'
			}
		},
		a_date     => { type => 'date' },
		a_time     => { type => 'time' },
		a_datetime => { type => 'datetime' },
		a_varchar  => { type => 'varchar', length => 128},
		a_text     => { type => 'text'}
	},
	'list_options' => {
		'default_sort' => 'varchar',
		'sort' => {
			'varchar' => 'a_varchar',
			'text' => 'a_text'
		}
	}
};



( run in 2.074 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )