Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab3719d

Browse files
author
Vladimir Ershov
committed
fix tests
1 parent3ef0582 commitab3719d

33 files changed

+119
-346
lines changed

‎test/perl/runtest.pl‎

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,96 @@
99
my$username;
1010
my$password;
1111
my$host;
12-
GetOptions ("--host=s"=> \$host,
12+
my$port;
13+
GetOptions (
14+
"--host=s"=> \$host,
15+
"--port=s"=> \$port,
1316
"--dbname=s"=> \$dbname,
1417
"--username=s"=> \$username,
1518
"--password=s"=> \$password);
1619

17-
print"Prepare test enviroment\n";
18-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
19-
{PrintError=> 1});
20-
if($dbh->err != 0){
21-
print$DBI::errstr ."\n";
22-
exit(-1);
23-
}
20+
$dbname ||='_pgpro_scheduler_test';
21+
$username ||='postgres';
2422

25-
my$query ="DROP TABLE IF EXISTS test_results;";
26-
$dbh->do($query);
27-
if($dbh->err != 0){
28-
print$DBI::errstr ."\n";
29-
exit(-1);
30-
}
23+
my$adm_dsn ='dbi:Pg:dbname=postgres';
24+
my$dsn ="dbi:Pg:dbname=$dbname";
3125

32-
$query ="CREATE TABLE test_results( time_mark timestamp, commentary text );";
33-
$dbh->do($query);
34-
if($dbh->err != 0){
35-
print$DBI::errstr ."\n";
36-
exit(-1);
26+
27+
if($host)
28+
{
29+
$adm_dsn +=";host=".$host;
30+
$dsn +=";host=".$host;
31+
}
32+
if($port)
33+
{
34+
$adm_dsn +=";port=".$port;
35+
$dsn +=";port=".$port;
3736
}
3837

39-
$query ="DROP ROLE IF EXISTS tester;";
40-
$dbh->do($query);
38+
print"Prepare test enviroment\n";
39+
my$dbh = DBI->connect($adm_dsn,$username,$password, {PrintError=> 1});
4140
if($dbh->err != 0){
4241
print$DBI::errstr ."\n";
4342
exit(-1);
4443
}
4544

46-
$query ="CREATE ROLE tester;";
47-
$dbh->do($query);
48-
if($DBI::err != 0){
49-
print$DBI::errstr ."\n";
50-
exit(-1);
51-
}
45+
my@sqls = (
46+
"ALTER SYSTEM SET schedule.enabled=off",
47+
"SELECT pg_reload_conf()",
48+
"DROP DATABASE IF EXISTS$dbname",
49+
"CREATE DATABASE$dbname",
50+
);
51+
52+
map { __do_sql($dbh,$_) }@sqls;
53+
$dbh->disconnect();
5254

53-
$query ="GRANT INSERT ON test_results TO tester;";
54-
$dbh->do($query);
55+
$dbh = DBI->connect($dsn,$username,$password, {PrintError=> 1});
5556
if($dbh->err != 0){
5657
print$DBI::errstr ."\n";
5758
exit(-1);
5859
}
5960

61+
my@sql2 = (
62+
"CREATE EXTENSION pgpro_scheduler",
63+
"ALTER DATABASE$dbname SET schedule.max_workers = 1",
64+
"ALTER SYSTEM SET schedule.database = '$dbname'",
65+
"ALTER SYSTEM SET schedule.enabled = on",
66+
"SELECT pg_reload_conf();",
67+
"CREATE TABLE test_results( time_mark timestamp, commentary text )",
68+
"DROP ROLE IF EXISTS tester",
69+
"CREATE ROLE tester",
70+
"GRANT INSERT ON test_results TO tester",
71+
);
72+
map { __do_sql($dbh,$_) }@sql2;
6073
$dbh->disconnect();
6174

6275
print"Run tests\n";
63-
my@db_param = ["--host=$host","--dbname=$dbname","--username=$username","--password=$password"];
76+
77+
my@db_param = ["--dbname=$dbname"];
78+
push@db_param,"--host=$host"if$host;
79+
push@db_param,"--port=$port"if$port;
80+
push@db_param,"--username=$username"if$username;
81+
push@db_param,"--password=$password"if$password;
82+
6483
my%args = (
6584
verbosity=> 1,
66-
test_args=>@db_param
85+
test_args=>\@db_param
6786
);
6887
my$harness = TAP::Harness->new( \%args );
6988
my@tests =glob('t/*.t' );
7089
$harness->runtests(@tests );
7190

7291

92+
sub__do_sql
93+
{
94+
my$dbh =shift;
95+
my$query =shift;
7396

74-
75-
76-
97+
print" ->$query\n";
98+
$dbh->do($query);
99+
if($dbh->err != 0)
100+
{
101+
printSTDERR"ON query:$query".$DBI::errstr."\n";
102+
exit(-1);
103+
}
104+
}

‎test/perl/t/_connect.pl‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use strict;
2+
use DBI;
3+
use Getopt::Long;
4+
5+
my$dbname;
6+
my$username;
7+
my$password;
8+
my$host;
9+
my$port;
10+
GetOptions (
11+
"--host=s"=> \$host,
12+
"--port=s"=> \$port,
13+
"--dbname=s"=> \$dbname,
14+
"--username=s"=> \$username,
15+
"--password=s"=> \$password);
16+
17+
$dbname ||='_pgpro_scheduler_test';
18+
19+
my$dsn ="dbi:Pg:dbname=$dbname";
20+
$dsn .=";host=".$hostif$host;
21+
$dsn .=";port=".$portif$port;
22+
23+
DBI->connect($dsn,$username,$password, {PrintError=> 1});
24+

‎test/perl/t/activateJob.t‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";
@@ -78,4 +69,4 @@ $sth->finish();
7869

7970
$dbh->disconnect();
8071

81-
done_testing();
72+
done_testing();

‎test/perl/t/createJobWithBadParam.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

‎test/perl/t/createJobWithCron.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

‎test/perl/t/createJobWithDate.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

‎test/perl/t/createJobWithDates.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

‎test/perl/t/createJobWithJsonb.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

‎test/perl/t/createSimpleJobWithBadParam.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

‎test/perl/t/createSimpleJobWithCron.t‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ use Test::More;
55
use DBI;
66
use Getopt::Long;
77

8-
my$dbname;
9-
my$username;
10-
my$password;
11-
my$host;
12-
GetOptions ("--host=s"=> \$host,
13-
"--dbname=s"=> \$dbname,
14-
"--username=s"=> \$username,
15-
"--password=s"=> \$password);
16-
my$dbh = DBI->connect("dbi:Pg:dbname=$dbname; host=$host","$username","$password",
17-
{PrintError=> 0});
8+
my$dbh =require't/_connect.pl';
189
ok($dbh->err == 0)or (print$DBI::errstrand BAIL_OUT);
1910

2011
my$query ="DELETE FROM test_results;";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp