TestRail-API-casefields.t 932 B

12345678910111213141516171819202122232425262728293031
  1. use strict;
  2. use warnings;
  3. use Test::More tests => 4;
  4. use Test::Deep;
  5. use TestRail::API;
  6. {
  7. my $this = { this => 'thing' };
  8. my $that = { that => 'thing' };
  9. my $theOther = { other => 'thing'};
  10. no warnings qw{redefine once};
  11. local *TestRail::API::_doRequest= sub { return $this };
  12. use warnings;
  13. my $tr = bless({},'TestRail::API');
  14. is_deeply($tr->getCaseFields(),$this, "getCaseFields appears to operate correctly on initial hit");
  15. no warnings qw{redefine once};
  16. local *TestRail::API::_doRequest= sub { my ($self,$url, $method, $input) = @_; return $that unless $method; return $input };
  17. use warnings;
  18. is_deeply($tr->getCaseFields(),$this, "getCaseFields caches correctly");
  19. is_deeply($tr->addCaseField(%$theOther),$theOther,"addCaseField appears to grab and pass options correctly");
  20. is_deeply($tr->getCaseFields(),$that, "getCaseFields invalidates cache correctly");
  21. }