-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cfdeb6
commit ec3c099
Showing
3 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require_relative "../../../../../lib/datadog/ci/test_retries/strategy/retry_new" | ||
|
||
RSpec.describe Datadog::CI::TestRetries::Strategy::RetryNew do | ||
let(:max_attempts) { 10 } | ||
let(:duration_thresholds) { | ||
Datadog::CI::Remote::SlowTestRetries.new({ | ||
"5s" => 10, | ||
"10s" => 5, | ||
"30s" => 3, | ||
"10m" => 2 | ||
}) | ||
} | ||
subject(:strategy) { described_class.new(duration_thresholds: duration_thresholds) } | ||
|
||
describe "#should_retry?" do | ||
subject { strategy.should_retry? } | ||
let(:test_span) { double(:test_span, set_tag: true) } | ||
|
||
context "when max attempts haven't been reached yet" do | ||
it { is_expected.to be true } | ||
end | ||
|
||
context "when the max attempts have been reached" do | ||
before { max_attempts.times { strategy.record_retry(test_span) } } | ||
|
||
it { is_expected.to be false } | ||
end | ||
end | ||
|
||
describe "#record_duration" do | ||
subject { strategy.record_duration(duration) } | ||
|
||
let(:duration) { 5 } | ||
|
||
it "updates the max attempts based on the duration" do | ||
expect { subject }.to change { strategy.instance_variable_get(:@max_attempts) }.from(10).to(5) | ||
end | ||
end | ||
end |