$bct->add_row_to_database('C', 2);
$bct->ctl('bucardo kick sync ctest 10');
-$bct->check_for_row([[1],[2]], [qw/ B C D/]);
+
+$bct->check_for_row([[1],[2]], [qw/ A B C D/]);
$t = q{Cannot set conflict handler to invalid database name};
$res = $bct->ctl('bucardo update sync ctest conflict="a b c"');
$bct->ctl('bucardo kick sync ctest 10');
$bct->check_for_row([[2],[1111]], [qw/ A B C D/]);
+## Test of the default conflict strategy
+$bct->update_row_in_database('B', 1, 102);
+$bct->update_row_in_database('A', 2, 201);
+$bct->update_row_in_database('B', 2, 202);
+$bct->add_row_to_database('A', 3);
+$bct->update_row_in_database('A', 3, 301);
+$bct->update_row_in_database('C', 2, 203);
+
+$t = q{Set conflict strategy to 'bucardo_latest'};
+$res = $bct->ctl('bucardo update sync ctest conflict=latest');
+like($res, qr{Set conflict strategy to 'bucardo_latest'}, $t);
+
+$t = q{Reloaded sync ctest};
+$res = $bct->ctl('bucardo reload sync ctest');
+like($res, qr{success}, $t);
+
+## Database B should be the winner for 1, C for 2, and A for 3
+$bct->ctl('bucardo kick sync ctest 10');
+$bct->check_for_row([[102],[203],[301]], [qw/ A B C D /]);
+
+## Test of conflict handler 'bucardo_latest_all_tables'
+$t = q{Set conflict strategy to 'bucardo_latest_all_tables'};
+$res = $bct->ctl('bucardo update sync ctest conflict=latest_all');
+like($res, qr{Set conflict strategy to 'bucardo_latest_all_tables'}, $t);
+
+$t = q{Reloaded sync ctest};
+$res = $bct->ctl('bucardo reload sync ctest');
+like($res, qr{success}, $t);
+
+$bct->update_row_in_database('B', 1, 102);
+$bct->update_row_in_database('A', 2, 201);
+$bct->update_row_in_database('B', 2, 202);
+$bct->update_row_in_database('A', 3, 301);
+$bct->update_row_in_database('C', 2, 203);
+
+## Database B should be the winner for 1, C for 2, and A for 3
+$bct->ctl('bucardo kick sync ctest 10');
+$bct->check_for_row([[102],[203],[301]], [qw/ A B C D /]);
+
+## Use a custom conflict handler by adding a customcode to this sync
+$t = q{Added new customcode ctest1 for conflict in the ctest sync};
+$res = $bct->ctl('bucardo add customcode ctest1 whenrun=conflict sync=ctest src_code=t/ctest1.pl');
+like($res, qr{Added customcode "ctest1"}, $t);
+
+$t = q{Reloaded sync ctest};
+$res = $bct->ctl('bucardo reload sync ctest');
+like($res, qr{success}, $t);
+
+$bct->update_row_in_database('A', 2, 211);
+$bct->update_row_in_database('B', 2, 212);
+$bct->update_row_in_database('C', 2, 213);
+$bct->update_row_in_database('A', 1, 111);
+$bct->update_row_in_database('C', 1, 113);
+$bct->ctl('bucardo kick sync ctest 10');
+$bct->check_for_row([[111],[212],[301]], [qw/ A B C D /]);
+
+## Customcode with winner
+
+## Customcode on a goat only
+
+
done_testing();
exit;