forked from base-org/pessimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Alert Cooldown Configurations (base-org#137)
- Loading branch information
Ethen Pociask
authored
Aug 9, 2023
1 parent
6a6d7e1
commit 650c4df
Showing
33 changed files
with
432 additions
and
199 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
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
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,44 @@ | ||
package alert_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/base-org/pessimism/internal/alert" | ||
"github.com/base-org/pessimism/internal/core" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_CoolDown(t *testing.T) { | ||
var testCases = []struct { | ||
name string | ||
construction func() alert.CoolDownHandler | ||
testFunc func(t *testing.T, cdh alert.CoolDownHandler) | ||
}{ | ||
{ | ||
name: "Test_CoolDownHandler", | ||
construction: alert.NewCoolDownHandler, | ||
testFunc: func(t *testing.T, cdh alert.CoolDownHandler) { | ||
// Add a cooldown for one second | ||
cdh.Add(core.NilSUUID(), time.Duration(1_000_000_000)) | ||
|
||
cooled := cdh.IsCoolDown(core.NilSUUID()) | ||
assert.True(t, cooled) | ||
|
||
// Sleep for one second | ||
time.Sleep(1_000_000_000) | ||
cdh.Update() | ||
cooled = cdh.IsCoolDown(core.NilSUUID()) | ||
assert.False(t, cooled) | ||
}, | ||
}, | ||
} | ||
|
||
for i, tc := range testCases { | ||
t.Run(fmt.Sprintf("%d-%s", i, tc.name), func(t *testing.T) { | ||
tc.testFunc(t, tc.construction()) | ||
}) | ||
} | ||
|
||
} |
Oops, something went wrong.