我正在尝试对 RT 系统进行单元测试,所以我需要在本地模拟一个 RT 实例。基本上,我正在连接到 RT 系统,并且正在处理工单的队列。有人有喜欢的代码示例或任何想法吗?我想我需要模拟 LWP::UserAgent 但我不确定。请出主意。提前致谢!
问问题
318 次
1 回答
2
在下面找到我的示例:
my $mock = Test::MockModule->new('REST::Client');
my $raw_response = '';
$mock->mock(
POST => sub { # You can do the same for GET :)
my ($ua, $request) = @_;
if ($request =~ /confirm/) {
$raw_response = $confirm_response_ok; # This is response for Confirm Method in my Code
}
elsif ($request =~ /transfers/) {
$raw_response = $create_response_ok; # This is response for Create transfer in my Code
}
return '';
},
responseCode => sub {
my $self = shift;
return '200';
},
responseContent => sub {
my $self = shift;
return $raw_response;
}
);
来自迈阿密的爱。你知道在哪里可以找到我们:)
埃维里奥和哈罗德
于 2017-06-30T21:10:54.580 回答