[Rt-commit] rt branch 5.0/shred-attachments-fts-index updated. rt-5.0.4-19-g5af6e0da67
BPS Git Server
git at git.bestpractical.com
Thu May 25 08:13:22 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/shred-attachments-fts-index has been updated
via 5af6e0da675895e25709d1c0e5d5a12e6fbdff28 (commit)
from b6487b80f52f88347a927d502d65556c544437b0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5af6e0da675895e25709d1c0e5d5a12e6fbdff28
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu May 25 11:13:11 2023 +0300
stab
diff --git a/lib/RT/Test/Shredder.pm b/lib/RT/Test/Shredder.pm
index 4c18a54d70..6360ffc8b4 100644
--- a/lib/RT/Test/Shredder.pm
+++ b/lib/RT/Test/Shredder.pm
@@ -59,46 +59,30 @@ require Cwd;
RT::Shredder test suite utilities
-=head1 TESTING
-
-Since RT:Shredder 0.01_03 we have a test suite. You
-can run tests and see if everything works as expected
-before you try shredder on your actual data.
-Tests also help in the development process.
-
-The test suite uses SQLite databases to store data in individual files,
-so you could sun tests on your production servers without risking
-damage to your production data.
-
-You'll want to run the test suite almost every time you install or update
-the shredder distribution, especialy if you have local customizations of
-the DB schema and/or RT code.
-
-Tests are one thing you can write even if you don't know much perl,
-but want to learn more about RT's internals. New tests are very welcome.
-
=head2 WRITING TESTS
The shredder distribution has several files to help write new tests.
- t/shredder/utils.pl - this file, utilities
- t/00skeleton.t - skeleteton .t file for new tests
+ lib/RT/Test/Shredder.pm - this file, utilities
+ t/shredder/00skeleton.t - skeleteton .t file for new tests
All tests follow this algorithm:
- require "t/shredder/utils.pl"; # plug in utilities
- init_db(); # create new tmp RT DB and init RT API
+ use RT::Test::Shredder tests => undef; # plug in utilities
+ my $test = "RT::Test::Shredder"; # alias for RT::Test::Shredder
# create RT data you want to be always in the RT DB
# ...
- create_savepoint('mysp'); # create DB savepoint
+ $test->create_savepoint('clean'); # create DB savepoint
# create data you want delete with shredder
# ...
# run shredder on the objects you've created
# ...
# check that shredder deletes things you want
# this command will compare savepoint DB with current
- cmp_deeply( dump_current_and_savepoint('mysp'), "current DB equal to savepoint");
+ cmp_deeply( $test->dump_current_and_savepoint('mysp'), "current DB equal to savepoint");
# then you can create another object and delete it, then check again
+ # ...
+ done_testing();
Savepoints are named and you can create two or more savepoints.
diff --git a/t/fts/indexed_mysql.t b/t/fts/indexed_mysql.t
index 672b220723..658cff125c 100644
--- a/t/fts/indexed_mysql.t
+++ b/t/fts/indexed_mysql.t
@@ -5,33 +5,16 @@ use warnings;
use RT::Test tests => undef;
plan skip_all => 'Not mysql' unless RT->Config->Get('DatabaseType') eq 'mysql';
+use RT::Test::FTS;
+
RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 1, Table => 'AttachmentsIndex' );
-setup_indexing();
+RT::Test::FTS->setup_indexing();
my $q = RT::Test->load_or_create_queue( Name => 'General' );
ok $q && $q->id, 'loaded or created queue';
my $queue = $q->Name;
-sub setup_indexing {
- my %args = (
- 'no-ask' => 1,
- command => $RT::SbinPath .'/rt-setup-fulltext-index',
- dba => $ENV{'RT_DBA_USER'},
- 'dba-password' => $ENV{'RT_DBA_PASSWORD'},
- );
- my ($exit_code, $output) = RT::Test->run_and_capture( %args );
- ok(!$exit_code, "setted up index") or diag "output: $output";
-}
-
-sub sync_index {
- my %args = (
- command => $RT::SbinPath .'/rt-fulltext-indexer',
- );
- my ($exit_code, $output) = RT::Test->run_and_capture( %args );
- ok(!$exit_code, "setted up index") or diag "output: $output";
-}
-
sub run_tests {
my @test = @_;
while ( my ($query, $checks) = splice @test, 0, 2 ) {
@@ -71,7 +54,7 @@ sub run_test {
{ Subject => 'third', Content => 'spanish' },
{ Subject => 'fourth', Content => 'german' },
);
-sync_index();
+RT::Test::FTS->sync_index();
run_tests(
"Content LIKE 'english'" => { first => 1, second => 0, third => 0, fourth => 0 },
diff --git a/t/fts/indexed_oracle.t b/t/fts/indexed_oracle.t
index a5b15bd825..bd634eb400 100644
--- a/t/fts/indexed_oracle.t
+++ b/t/fts/indexed_oracle.t
@@ -8,31 +8,12 @@ plan tests => 13;
RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 1, IndexName => 'rt_fts_index' );
-setup_indexing();
+RT::Test::FTS->setup_indexing();
my $q = RT::Test->load_or_create_queue( Name => 'General' );
ok $q && $q->id, 'loaded or created queue';
my $queue = $q->Name;
-sub setup_indexing {
- my %args = (
- 'no-ask' => 1,
- command => $RT::SbinPath .'/rt-setup-fulltext-index',
- dba => $ENV{'RT_DBA_USER'},
- 'dba-password' => $ENV{'RT_DBA_PASSWORD'},
- );
- my ($exit_code, $output) = RT::Test->run_and_capture( %args );
- ok(!$exit_code, "setted up index") or diag "output: $output";
-}
-
-sub sync_index {
- my %args = (
- command => $RT::SbinPath .'/rt-fulltext-indexer',
- );
- my ($exit_code, $output) = RT::Test->run_and_capture( %args );
- ok(!$exit_code, "synced the index") or diag "output: $output";
-}
-
sub run_tests {
my @test = @_;
while ( my ($query, $checks) = splice @test, 0, 2 ) {
@@ -70,7 +51,7 @@ sub run_test {
{ Subject => 'book', Content => 'book' },
{ Subject => 'bar', Content => 'bar' },
);
-sync_index();
+RT::Test::FTS->sync_index();
run_tests(
"Content LIKE 'book'" => { book => 1, bar => 0 },
diff --git a/t/fts/indexed_pg.t b/t/fts/indexed_pg.t
index 1494fded25..4ec2fd40b2 100644
--- a/t/fts/indexed_pg.t
+++ b/t/fts/indexed_pg.t
@@ -5,37 +5,20 @@ use warnings;
use RT::Test tests => undef;
plan skip_all => 'Not Pg' unless RT->Config->Get('DatabaseType') eq 'Pg';
+use RT::Test::FTS;
+
my ($major, $minor) = $RT::Handle->dbh->get_info(18) =~ /^0*(\d+)\.0*(\d+)/;
plan skip_all => "Need Pg 8.2 or higher; we have $major.$minor"
if "$major.$minor" < 8.2;
RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 1, Column => 'ContentIndex', Table => 'AttachmentsIndex' );
-setup_indexing();
+RT::Test::FTS->setup_indexing();
my $q = RT::Test->load_or_create_queue( Name => 'General' );
ok $q && $q->id, 'loaded or created queue';
my $queue = $q->Name;
-sub setup_indexing {
- my %args = (
- 'no-ask' => 1,
- command => $RT::SbinPath .'/rt-setup-fulltext-index',
- dba => $ENV{'RT_DBA_USER'},
- 'dba-password' => $ENV{'RT_DBA_PASSWORD'},
- );
- my ($exit_code, $output) = RT::Test->run_and_capture( %args );
- ok(!$exit_code, "setted up index") or diag "output: $output";
-}
-
-sub sync_index {
- my %args = (
- command => $RT::SbinPath .'/rt-fulltext-indexer',
- );
- my ($exit_code, $output) = RT::Test->run_and_capture( %args );
- ok(!$exit_code, "setted up index") or diag "output: $output";
-}
-
sub run_tests {
my @test = @_;
while ( my ($query, $checks) = splice @test, 0, 2 ) {
@@ -74,7 +57,7 @@ my $blase = Encode::decode_utf8("blasé");
{ Subject => 'fts test 1', Content => "book $blase" },
{ Subject => 'fts test 2', Content => "bars blasé", ContentType => 'text/html' },
);
-sync_index();
+RT::Test::FTS->sync_index();
my $book = $tickets[0];
my $bars = $tickets[1];
-----------------------------------------------------------------------
Summary of changes:
lib/RT/Test/Shredder.pm | 32 ++++++++------------------------
t/fts/indexed_mysql.t | 25 ++++---------------------
t/fts/indexed_oracle.t | 23 ++---------------------
t/fts/indexed_pg.t | 25 ++++---------------------
4 files changed, 18 insertions(+), 87 deletions(-)
hooks/post-receive
--
rt
More information about the rt-commit
mailing list