Games-Go-AGA-TDListDB
view release on metacpan or search on metacpan
t/001-TDList.t view on Meta::CPAN
is ($player->[1], 'Yzz', 'first name of new player');
is ($player->[2], 'TMP3', 'ID of new player');
is ($player->[4], '5.5', 'rank of new player');
my $thrown = 0;
try {
update_from_string('Augustin, Reid 2122 Comp 4.2 4/27/1929 AbCd MI');
}
catch {
my $error = $_;
fail "Oops: $error";
$thrown = 1;
};
ok ($thrown == 0, 'exception not thrown for rank change');
$thrown = 0;
try {
update_from_string('Augustin, Yyx 2122 Youth 1.1 4/27/1929 SFGC MI');
}
catch {
my $error = $_;
fail "Oops: $error";
$thrown = 1;
};
ok ($thrown == 0, 'exception not thrown for valid ID change');
is ($tdlistdb->next_tmp_id(1), 'TMP4', 'next_tmp_id is TMP4');
is ($tdlistdb->next_tmp_id(1), 'TMP5', 'next_tmp_id is TMP5');
$tdlistdb->background(0); # run update in the background
is ($tdlistdb->background, 0, 'net update in background (takes a few seconds)');
print 'start update at ', scalar localtime, "\n";
# $tdlistdb->update_from_AGA;
# while ($tdlistdb->reap == 0) {
# print 'not yet, ';
# sleep 1;
# }
# print 'update done at ', scalar localtime, "\n";
#
# $player = $tdlistdb->select_id('USA7206');
# is ($player->[0], 'Aaron', 'W. Aaron was added');
#$tdlistdb->db->disconnect;
# clean up
if (not defined $DB::single or not defined $DB::single) {
unlink $db_fname;
}
sub fetch_player {
my ($last_name, $first_name) = @_;
$tdlistdb->sth('select_by_name')->execute($last_name, $first_name);
my $found = $tdlistdb->sth('select_by_name')->fetchall_arrayref;
croak("Too many copies of $last_name, $first_name\n") if (@{$found} > 1);
return $found->[0];
}
sub update_from_string {
my ($string) = @_;
my $ref = ref $string ? $string : \$string;
my $fh;
open($fh, '<', $ref)
or croak("Error opening \$string for reading: $!\n");
$tdlistdb->update_from_file($fh);
}
__END__
( run in 2.884 seconds using v1.01-cache-2.11-cpan-364913b4093 )