@@ -12,9 +12,9 @@ func TestCreate(t *testing.T) {
1212 assert .False (t , hotstreak .IsActive ())
1313 assert .False (t , hotstreak .IsHot ())
1414 assert .Equal (t , hotstreak .counter , 0 )
15- assert .Equal (t , hotstreak .Limit , 20 )
16- assert .Equal (t , hotstreak .ActiveWait , time .Minute * 5 )
17- assert .Equal (t , hotstreak .HotWait , time .Minute * 5 )
15+ assert .Equal (t , hotstreak .config . Limit , 20 )
16+ assert .Equal (t , hotstreak .config . ActiveWait , time .Minute * 5 )
17+ assert .Equal (t , hotstreak .config . HotWait , time .Minute * 5 )
1818}
1919
2020func TestActivation (t * testing.T ) {
@@ -24,14 +24,6 @@ func TestActivation(t *testing.T) {
2424 assert .True (t , hotstreak .IsActive ())
2525 })
2626
27- t .Run ("Should be able to end activation after wait time" , func (t * testing.T ) {
28- hotstreak := New (Config {ActiveWait : time .Millisecond * 500 })
29- hotstreak .Activate ()
30- assert .True (t , hotstreak .IsActive ())
31- <- time .After (time .Second )
32- assert .False (t , hotstreak .IsActive ())
33- })
34-
3527 t .Run ("Should not deactivate if any hit has been made in the activation time" , func (t * testing.T ) {
3628 hotstreak := New (Config {ActiveWait : time .Millisecond * 500 })
3729 hotstreak .Activate ()
@@ -45,6 +37,24 @@ func TestActivation(t *testing.T) {
4537 })
4638}
4739
40+ func TestDeactivation (t * testing.T ) {
41+ t .Run ("Should be able to end activation after wait time" , func (t * testing.T ) {
42+ hotstreak := New (Config {ActiveWait : time .Millisecond * 500 })
43+ hotstreak .Activate ()
44+ assert .True (t , hotstreak .IsActive ())
45+ <- time .After (time .Second )
46+ assert .False (t , hotstreak .IsActive ())
47+ })
48+
49+ t .Run ("Should not be able to end activation after wait time if active set to always" , func (t * testing.T ) {
50+ hotstreak := New (Config {ActiveWait : time .Millisecond * 500 , AlwaysActive : true })
51+ hotstreak .Activate ()
52+ assert .True (t , hotstreak .IsActive ())
53+ <- time .After (time .Second )
54+ assert .True (t , hotstreak .IsActive ())
55+ })
56+ }
57+
4858func TestHitting (t * testing.T ) {
4959 t .Run ("Should be able to reach being hot" , func (t * testing.T ) {
5060 hotstreak := New (Config {Limit : 2 })
0 commit comments