TestRail-Utils.t 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. use strict;
  2. use warnings;
  3. use Test::More 'tests' => 10;
  4. use Test::Fatal;
  5. use TestRail::Utils;
  6. use File::Basename qw{dirname};
  7. my ($apiurl,$user,$password);
  8. #check the binary output mode
  9. is(exception {($apiurl,$password,$user) = TestRail::Utils::parseConfig(dirname(__FILE__),1)}, undef, "No exceptions thrown by parseConfig in array mode");
  10. is($apiurl,'http://hokum.bogus',"APIURL parse OK");
  11. is($user,'zippy',"USER parse OK");
  12. is($password, 'happy', 'PASSWORD parse OK');
  13. my $out;
  14. is(exception {$out = TestRail::Utils::parseConfig(dirname(__FILE__))}, undef, "No exceptions thrown by parseConfig default mode");
  15. is($out->{apiurl},'http://hokum.bogus',"APIURL parse OK");
  16. is($out->{user},'zippy',"USER parse OK");
  17. is($out->{password}, 'happy', 'PASSWORD parse OK');
  18. #Handle both the case where we do in sequence or in paralell and mash together logs
  19. my @files;
  20. my $fcontents = '';
  21. open(my $fh,'<','t/test_multiple_files.tap') or die("couldn't open our own test files!!!");
  22. while (<$fh>) {
  23. if (TestRail::Utils::getFilenameFromTapLine($_)) {
  24. push(@files,$fcontents) if $fcontents;
  25. $fcontents = '';
  26. }
  27. $fcontents .= $_;
  28. }
  29. close($fh);
  30. push(@files,$fcontents);
  31. is(scalar(@files),2,"Detects # of filenames correctly in TAP");
  32. $fcontents = '';
  33. @files = ();
  34. open($fh,'<','t/seq_multiple_files.tap') or die("couldn't open our own test files!!!");
  35. while (<$fh>) {
  36. if (TestRail::Utils::getFilenameFromTapLine($_)) {
  37. push(@files,$fcontents) if $fcontents;
  38. $fcontents = '';
  39. }
  40. $fcontents .= $_;
  41. }
  42. close($fh);
  43. push(@files,$fcontents);
  44. is(scalar(@files),7,"Detects # of filenames correctly in TAP");
  45. #Regrettably, I have yet to find a way to print to stdin without eval, so userInput will remain untested.