TestRail-Utils.t 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. diag explain \@files;
  32. is(scalar(@files),2,"Detects # of filenames correctly in TAP");
  33. $fcontents = '';
  34. @files = ();
  35. open($fh,'<','t/seq_multiple_files.tap') or die("couldn't open our own test files!!!");
  36. while (<$fh>) {
  37. if (TestRail::Utils::getFilenameFromTapLine($_)) {
  38. push(@files,$fcontents) if $fcontents;
  39. $fcontents = '';
  40. }
  41. $fcontents .= $_;
  42. }
  43. close($fh);
  44. push(@files,$fcontents);
  45. diag explain \@files;
  46. is(scalar(@files),7,"Detects # of filenames correctly in TAP");
  47. #Regrettably, I have yet to find a way to print to stdin without eval, so userInput will remain untested.