9. CREATE TABLE changed_table (
changed_table_id INT(11)
NOT NULL AUTO_INCREMENT PRIMARY KEY,
table_name VARCHAR(30) NOT NULL,
is_static INT NOT NULL DEFAULT 0,
inserts INT NOT NULL DEFAULT 0,
updates INT NOT NULL DEFAULT 0,
deletes INT NOT NULL DEFAULT 0
)
-- then insert table records
Tuesday, 7 October 2008
10. foreach my $action (qw/insert update delete/) {
$dbh->do(<<quot; END_SQLquot;);
CREATE TRIGGER tr_${action}_$table
BEFORE $action ON $table
FOR EACH ROW UPDATE changed_table
SET ${action}s = ${action}s + 1
WHERE table_name = '$table';
END_SQL
}
Tuesday, 7 October 2008
11. db.disable_foreign_keys()
for table in changed_tables()
table.truncate()
if table.is_static()
table.rebuild()
db.enable_foreign_keys()
Tuesday, 7 October 2008
13. Aggregation
• Only load things once
• Dangers of shared state
Tuesday, 7 October 2008
14. use My::YAML::Test;
My::YAML::Test->run;
# t/api/customer.t
# t/api/customer.yml
Tuesday, 7 October 2008
15. use My::YAML::Test;
foreach (yaml_tests()) {
diag “running $_”;
My::YAML::Test->run($_);
}
sub yaml_tests {
return @ARGV if @ARGV;
# or return all YAML files ...
}
Tuesday, 7 October 2008
30. use Test::Most tests => 4, 'die';
ok 1, 'one is true';
is 2, 2, '... and two is two';
eq_or_diff [3], [4],
“... but three ain’t four”;
throws_ok { $foo/0 }
qr/Illegal division by zero/,
'and no-constant folding with vars';
Tuesday, 7 October 2008
33. vim $(ack -l --perl 'api/v1/episode' t/)
map <leader>tb :call RunTestsInBuffers()<cr>
function! RunTestsInBuffers()
let i = 1
let tests = ''
while (i <= bufnr(quot;$quot;))
let filename = bufname(i)
if match(filename, '.t$') > -1
let tests = tests . ' quot;' . filename . 'quot;'
endif
let i = i+1
endwhile
if !strlen(tests)
echo quot;No tests found in buffersquot;
else
execute ':!prove ' . tests
endif
endfunction
Tuesday, 7 October 2008
39. Devel::CoverX::Covered
• What tests cover this file?
• What files are covered by this test?
• (Soon) What tests cover this line?
• (Soon) What tests cover this subroutine?
• ... and more ...
Tuesday, 7 October 2008