Skip to content

Commit

Permalink
fix retry calculation test
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Feb 22, 2024
1 parent 6998268 commit 9b2edb2
Showing 1 changed file with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,43 +248,60 @@ func TestPacker_UnpackCheckCallbackResult(t *testing.T) {

func Test_CalculateRetryConfigFn(t *testing.T) {
tests := []struct {
name string
times int
expected time.Duration
name string
times int
upkeepType automationTypes.UpkeepType
expected time.Duration
}{
{
name: "first retry",
times: 1,
expected: 1 * time.Second,
name: "log trigger first retry",
times: 1,
upkeepType: automationTypes.LogTrigger,
expected: 1 * time.Second,
},
{
name: "second retry",
times: 2,
expected: 1 * time.Second,
name: "log trigger second retry",
times: 2,
upkeepType: automationTypes.LogTrigger,
expected: 1 * time.Second,
},
{
name: "fifth retry",
times: 5,
expected: 1 * time.Second,
name: "log trigger fifth retry",
times: 5,
upkeepType: automationTypes.LogTrigger,
expected: 1 * time.Second,
},
{
name: "sixth retry",
times: 6,
expected: 5 * time.Second,
name: "log trigger sixth retry",
times: 6,
upkeepType: automationTypes.LogTrigger,
expected: 5 * time.Second,
},
{
name: "timeout",
name: "log trigger timeout",
times: totalMediumPluginRetries + 1,
expected: RetryIntervalTimeout,
},
{
name: "conditional trigger first retry",
times: 1,
upkeepType: automationTypes.ConditionTrigger,
expected: RetryIntervalTimeout,
},
{
name: "conditional trigger timeout",
times: totalMediumPluginRetries + 1,
upkeepType: automationTypes.ConditionTrigger,
expected: RetryIntervalTimeout,
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
cfg := newMercuryConfigMock()
var result time.Duration
for i := 0; i < tc.times; i++ {
result = CalculateStreamsRetryConfigFn(automationTypes.ConditionTrigger, "prk", cfg)
result = CalculateStreamsRetryConfigFn(tc.upkeepType, "prk", cfg)
}
assert.Equal(t, tc.expected, result)
})
Expand Down

0 comments on commit 9b2edb2

Please sign in to comment.