generate_testing_configuration.pl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use File::Basename qw{dirname};
  5. use Cwd qw{abs_path};
  6. my $gitdir = abs_path( dirname( __FILE__ ) . "/.." );
  7. unshift @INC, "$gitdir/lib";
  8. print "Please input the provider name you are attempting to test: ";
  9. chomp( my $input = <STDIN> );
  10. $input = uc($input);
  11. my $module_name = $input;
  12. if( $input eq 'SLACK' ) {
  13. $module_name = 'Slack';
  14. }
  15. my $package = "Cpanel::iContact::Provider::Schema::$module_name";
  16. my $ret = eval "require $package";
  17. die "Couldn't load $package! Check input or file permissions" if !$ret;
  18. my $settings_hr = $package->get_settings();
  19. my $file_name_prefix = lc( $input );
  20. open( my $fh, ">", "$gitdir/.${file_name_prefix}testrc" );
  21. foreach my $key ( keys( %$settings_hr ) ) {
  22. print "Please input the '", $settings_hr->{$key}{'label'}, "' ($key): ";
  23. print $fh "$key: " . <STDIN>;
  24. }
  25. close( $fh );
  26. print STDOUT (
  27. "Done writing to $gitdir/.${file_name_prefix}testrc.\n",
  28. "The functional test in t/ should now work when ran like so:\n",
  29. "AUTHOR_TESTS=1 prove $gitdir/t/Cpanel-iContact-Provider-$module_name.t\n"
  30. );
  31. 0;