cvs commit: p5ee/App-Repository/t Repository-expr.t DBI-compress.t DBI-connect.t DBI-delete.t DBI-getset.t DBI-insert.t DBI-metadata.t DBI-select.t DBI-update.t

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     05/10/20 13:08:38

  Modified:    App-Repository/t DBI-compress.t DBI-connect.t DBI-delete.t
                        DBI-getset.t DBI-insert.t DBI-metadata.t
                        DBI-select.t DBI-update.t
  Added:       App-Repository/t Repository-expr.t
  Log:
  trying to make tests consult app.conf and succeed if one does not exist
  
  Revision  Changes    Path
  1.2       +7 -2      p5ee/App-Repository/t/DBI-compress.t
  
  Index: DBI-compress.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-compress.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DBI-compress.t	25 Apr 2005 16:20:26 -0000	1.1
  +++ DBI-compress.t	20 Oct 2005 20:08:37 -0000	1.2
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use App::Repository;
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
       %App::options,
       conf_file => "",
  
  
  
  1.5       +12 -7     p5ee/App-Repository/t/DBI-connect.t
  
  Index: DBI-connect.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-connect.t,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DBI-connect.t	9 Aug 2005 18:56:19 -0000	1.4
  +++ DBI-connect.t	20 Oct 2005 20:08:37 -0000	1.5
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use_ok("App::Repository");
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   #$App::DEBUG = 6;
   
   {
  @@ -64,11 +69,11 @@
       #$App::aspect = 1;
       # get a repository (no need for config file)
       my $rep = App::Repository::MySQL->new("test2",
  -        dbidriver => "mysql",
  -        dbhost => "frento",
  -        dbname => "test",
  -        dbuser => "dbuser",
  -        dbpass => "dbuser7",
  +        dbdriver => $App::options{dbdriver},
  +        dbhost => $App::options{dbhost},
  +        dbname => $App::options{dbname},
  +        dbuser => $App::options{dbuser},
  +        dbpass => $App::options{dbpass},
       );
       ok(defined $rep, "constructor ok");
       isa_ok($rep, "App::Repository::DBI", "right class");
  
  
  
  1.6       +7 -2      p5ee/App-Repository/t/DBI-delete.t
  
  Index: DBI-delete.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-delete.t,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DBI-delete.t	25 Apr 2005 16:20:26 -0000	1.5
  +++ DBI-delete.t	20 Oct 2005 20:08:38 -0000	1.6
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use App::Repository;
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
     conf_file => "",
     conf => {
  
  
  
  1.8       +14 -3     p5ee/App-Repository/t/DBI-getset.t
  
  Index: DBI-getset.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-getset.t,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DBI-getset.t	25 Apr 2005 16:20:26 -0000	1.7
  +++ DBI-getset.t	20 Oct 2005 20:08:38 -0000	1.8
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use App::Repository;
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
       conf_file => "",
       conf => {
  @@ -41,7 +46,7 @@
               },
           },
       },
  -    #debug_sql => 1,
  +    debug_sql => $App::options{debug_sql},
   );
   
   my $rep = $context->repository();
  @@ -160,6 +165,12 @@
   is($rep->set("test_person", {gender => "F", age => 41}), 0,
       "set(table,\$params,\%hash) : fails if key not supplied");
   $hashes = $rep->get_hashes("test_person");
  +is($#$hashes, 7, "get_hashes(test_person) returned 8 rows");
  +$hashes = $rep->get_hashes("test_person",{},undef,{order_by=>["person_id"]});
  +is($#$hashes, 7, "get_hashes(test_person,{},undef,{order_by}) returned 8 rows");
  +#foreach $hash (@$hashes) {
  +#    print "HASH: {", join("|", %$hash), "}\n";
  +#}
   $hash = $hashes->[0];
   is($hash->{person_id},  1,         "get_hashes()->[0] person_id");
   is($hash->{age},        41,        "get_hashes()->[0] age");
  
  
  
  1.5       +7 -2      p5ee/App-Repository/t/DBI-insert.t
  
  Index: DBI-insert.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-insert.t,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DBI-insert.t	25 Apr 2005 16:20:26 -0000	1.4
  +++ DBI-insert.t	20 Oct 2005 20:08:38 -0000	1.5
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use_ok("App::Repository");
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
       conf_file => "",
       conf => {
  
  
  
  1.4       +7 -2      p5ee/App-Repository/t/DBI-metadata.t
  
  Index: DBI-metadata.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-metadata.t,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DBI-metadata.t	25 Apr 2005 16:20:26 -0000	1.3
  +++ DBI-metadata.t	20 Oct 2005 20:08:38 -0000	1.4
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use App::Repository;
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
       conf_file => "",
       conf => {
  
  
  
  1.12      +7 -2      p5ee/App-Repository/t/DBI-select.t
  
  Index: DBI-select.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-select.t,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DBI-select.t	25 Apr 2005 16:20:26 -0000	1.11
  +++ DBI-select.t	20 Oct 2005 20:08:38 -0000	1.12
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use App::Repository;
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
       conf_file => "",
       conf => {
  
  
  
  1.5       +7 -2      p5ee/App-Repository/t/DBI-update.t
  
  Index: DBI-update.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-update.t,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DBI-update.t	25 Apr 2005 16:20:26 -0000	1.4
  +++ DBI-update.t	20 Oct 2005 20:08:38 -0000	1.5
  @@ -7,8 +7,8 @@
           dbdriver => { default => "mysql", },
           dbhost   => { default => "localhost", },
           dbname   => { default => "test", },
  -        dbuser   => { default => "scott", },
  -        dbpass   => { default => "tiger", },
  +        dbuser   => { default => "", },
  +        dbpass   => { default => "", },
       },
   );
   
  @@ -22,6 +22,11 @@
   use App::Repository;
   use strict;
   
  +if (!$App::options{dbuser}) {
  +    ok(1, "No dbuser given. Tests assumed OK. (add dbuser=xxx and dbpass=yyy to app.conf in 't' directory)");
  +    exit(0);
  +}
  +
   my $context = App->context(
       conf_file => "",
       conf => {
  
  
  
  1.1                  p5ee/App-Repository/t/Repository-expr.t
  
  Index: Repository-expr.t
  ===================================================================
  #!/usr/local/bin/perl -w
  
  use Test::More qw(no_plan);
  use lib "../App-Context/lib";
  use lib "../../App-Context/lib";
  use lib "lib";
  use lib "../lib";
  
  use_ok("App");
  use_ok("App::Repository");
  use strict;
  
  {
      is(App::Repository->evaluate_constant_expression("1"), 1, "eval: 1");
      is(App::Repository->evaluate_constant_expression("-1.5"), -1.5, "eval: -1.5");
      is(App::Repository->evaluate_constant_expression(" 2   "), 2, "eval: 2");
      is(App::Repository->evaluate_constant_expression("  -1.5"), -1.5, "eval: [sp]-1.5");
      is(App::Repository->evaluate_constant_expression("-1.5   "), -1.5, "eval: -1.5[sp]");
      is(App::Repository->evaluate_constant_expression("  -1.5   "), -1.5, "eval: [sp]-1.5[sp]");
      is(App::Repository->evaluate_constant_expression("2+4"), 6, "eval: 2+4");
      is(App::Repository->evaluate_constant_expression("2-4"), -2, "eval: 2-4");
      is(App::Repository->evaluate_constant_expression("2*4"), 8, "eval: 2*4");
      is(App::Repository->evaluate_constant_expression("2/4"), .5, "eval: 2/4");
      is(App::Repository->evaluate_constant_expression("2+-4"), -2, "eval: 2+-4");
      is(App::Repository->evaluate_constant_expression("2--4"), 6, "eval: 2--4");
      is(App::Repository->evaluate_constant_expression("2*-4"), -8, "eval: 2*-4");
      is(App::Repository->evaluate_constant_expression("2/-4"), -.5, "eval: 2/-4");
      is(App::Repository->evaluate_constant_expression("-2+-4"), -6, "eval: -2+-4");
      is(App::Repository->evaluate_constant_expression("-2--4"), 2, "eval: -2--4");
      is(App::Repository->evaluate_constant_expression("-2*-4"), 8, "eval: -2*-4");
      is(App::Repository->evaluate_constant_expression("-2/-4"), .5, "eval: -2/-4");
      is(App::Repository->evaluate_constant_expression("1+2*3"), 7, "eval: 1+2*3");
      is(App::Repository->evaluate_constant_expression("1*2+3"), 5, "eval: 1*2+3");
      is(App::Repository->evaluate_constant_expression("1*(2+3)"), 5, "eval: 1*(2+3)");
      is(App::Repository->evaluate_constant_expression("((1-(2*3))+(12-5))*3"), 6, "eval: ((1-(2*3))+(12-5))*3");
  
      my %values = (
          x  => 3,
          y  => 4,
          r2 => "{x}*{x}+{y}*{y}",
          z  => 0,
          r  => 5,
          pi => 3.1415926535259,
      );
      my @cols = qw(x y r2 z r pi);
      my @values = @values{@cols};
      my (%validx);
      for (my $i = 0; $i <= $#cols; $i++) {
          $validx{$cols[$i]} = $i;
      }
  
      # tests on rows (hashrefs) of data
      is(App::Repository->evaluate_expression("{x}*{x}+{y}*{y}",\%values), 25, "eval: {x}*{x}+{y}*{y}");
      is(App::Repository->evaluate_expression("{x}/{z}",\%values), undef, "eval: {x}/{z}");
      is(App::Repository->evaluate_expression("{x}/{z}+{y}*{y}",\%values), undef, "eval: {x}/{z}+{y}*{y}");
      is(App::Repository->evaluate_expression("2*{r2}",\%values), 50, "eval: 2*{r2}");
  
      # tests on rows (arrayrefs) of data
      is(App::Repository->evaluate_expression("{x}*{x}+{y}*{y}",\@values, \%validx), 25, "eval: {x}*{x}+{y}*{y}");
      is(App::Repository->evaluate_expression("{x}/{z}",\@values, \%validx), undef, "eval: {x}/{z}");
      is(App::Repository->evaluate_expression("{x}/{z}+{y}*{y}",\@values, \%validx), undef, "eval: {x}/{z}+{y}*{y}");
      is(App::Repository->evaluate_expression("2*{r2}",\@values, \%validx), 50, "eval: 2*{r2}");
  }
  
  exit 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.