[Bast-commits] r8074 - DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin

goraxe at dev.catalyst.perl.org goraxe at dev.catalyst.perl.org
Sat Dec 12 16:36:59 GMT 2009


Author: goraxe
Date: 2009-12-12 16:36:58 +0000 (Sat, 12 Dec 2009)
New Revision: 8074

Added:
   DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/03data.t
Log:
add tests for data manipulation ported from 89dbicadmin.t

Added: DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/03data.t
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/03data.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/03data.t	2009-12-12 16:36:58 UTC (rev 8074)
@@ -0,0 +1,84 @@
+#
+#===============================================================================
+#
+#         FILE:  03sql.t
+#
+#  DESCRIPTION:  test sql manipulation funtions
+#
+#        FILES:  ---
+#         BUGS:  ---
+#        NOTES:  ---
+#       AUTHOR:  Gordon Irving (), <Gordon.irving at sophos.com>
+#      VERSION:  1.0
+#      CREATED:  12/12/09 12:44:57 GMT
+#     REVISION:  ---
+#===============================================================================
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Test::Exception;
+use Test::Deep;
+
+use Path::Class;
+use FindBin qw($Bin);
+
+use lib dir($Bin,'..', '..','lib')->stringify;
+use lib dir($Bin,'..', 'lib')->stringify;
+
+use ok 'DBIx::Class::Admin';
+
+use DBICTest;
+
+{ # test data maniplulation functions
+
+	# create a DBICTest so we can steal its connect info
+	my $schema = DBICTest->init_schema(
+	#    no_deploy=>1,
+	#	no_populate=>1,
+		sqlite_use_file => 1,
+		);
+
+
+	my $admin = DBIx::Class::Admin->new(
+		schema_class=> "DBICTest::Schema",
+		connect_info => $schema->storage->connect_info(),
+		quiet	=> 1,
+		_confirm=>1,
+	);
+	isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object');
+
+	$admin->insert_data('Employee', { name => 'Matt' });
+	my $employees = $schema->resultset('Employee');
+	is ($employees->count(), 1, "insert okay" );
+
+	my $employee = $employees->find(1);
+	is($employee->name(),  'Matt', "insert valid" );
+
+	$admin->update_data('Employee', {name => 'Trout'}, {name => 'Matt'});
+
+	$employee = $employees->find(1);
+	is($employee->name(),  'Trout', "update Matt to Trout" );
+
+	$admin->insert_data('Employee', {name =>'Aran'});
+
+	my $expected_data = [ 
+		[$employee->result_source->columns() ],
+		[1,1,undef,undef,undef,'Trout'],
+		[2,2,undef,undef,undef,'Aran']
+	];
+	my $data;
+	lives_ok { $data = $admin->select_data('Employee')} 'can retrive data from database';
+	cmp_deeply($data, $expected_data, 'DB matches whats expected');
+
+	$admin->delete_data('Employee', {name=>'Trout'});
+	my $del_rs  = $employees->search({name => 'Trout'});
+	is($del_rs->count(), 0, "delete Trout" );
+	is ($employees->count(), 1, "left Aran" );
+}
+
+
+
+done_testing;




More information about the Bast-commits mailing list