Browse files

added some tests for SimpleServer constructor

  • Loading branch information...
1 parent a62ac40 commit 8708fa558262fda74fcd3ae8dca2c08ae90d783b @russoz committed Nov 8, 2010
Showing with 20 additions and 33 deletions.
  1. +20 −33 t/03.param.t
View
53 t/03.param.t
@@ -1,43 +1,30 @@
-use Test::More tests => 0;
-
-__DATA__
-
-use Net::LDAP::SimpleServer;
+use Test::More tests => 3;
sub _check_param {
- eval { Net::LDAP::SimpleServer->new(@_) };
-}
-sub check_param_success {
- my $p = _check_param(@_);
- ok($p);
-}
+ #diag( join ',', @_ );
+ eval {
+ use Net::LDAP::SimpleServer;
+ my $s = Net::LDAP::SimpleServer->new(@_);
+ $s->run();
+ };
-sub check_param_failure {
- my $p = _check_param(@_);
- ok( not $p );
+ #diag( '$@ = ' . $@ );
+ return $@;
}
-diag("Testing parameters for the constructor\n");
-
-check_param_failure('name/of/a/file/that/will/never/ever/exist!');
-
-use File::HomeDir;
-use File::Spec::Functions qw(catfile);
+sub check_failure {
+ ok( _check_param(@_) );
+}
-my $cfgfile =
- catfile( home(), Net::Squid::Auth::Plugin::SimpleLDAP::DEFAULT_CONFIG_FILE );
+diag('Testing the constructor params for SimpleServer');
-if ( -r $cfgfile ) {
- diag( "Using default cfg file: " . $cfgfile );
- check_param_success();
-}
-else {
- diag("Default cfg file not found");
- check_param_failure();
-}
+check_failure();
+check_failure( {} );
-#SKIP: {
-# skip "Not messing with your default configuration file", 1
-# if -r $cfgfile;
+# Cannot test for non-existent configuration file right now
+# because Net::Server calls exit() when that happens >:-\
+#
+#check_failure( { conf_file => 'examples/no/file.conf' } );
+check_failure( { data => 'examples/test1.ldif' } );

0 comments on commit 8708fa5

Please sign in to comment.