[MM-8497] Ability to set Do Not Disturb for a specified period of time (#17680)
* Revert "Revert "[MM-8497] Ability to set Do Not Disturb for a specified period of time (#16067)" (#17657)"
This reverts commit ff383990f8.
* add debug log for recurring function
* add feature flag for dnd timed status
* refactoring changes
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -4,6 +4,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -73,3 +74,35 @@ func TestCancelTask(t *testing.T) {
|
||||
time.Sleep(TASK_TIME + time.Second)
|
||||
assert.EqualValues(t, 0, atomic.LoadInt32(executionCount))
|
||||
}
|
||||
|
||||
func TestCreateRecurringTaskFromNextIntervalTime(t *testing.T) {
|
||||
TASK_NAME := "Test Recurring Task starting from next interval time"
|
||||
TASK_TIME := time.Second * 2
|
||||
|
||||
var executionTime time.Time
|
||||
var mu sync.Mutex
|
||||
testFunc := func() {
|
||||
mu.Lock()
|
||||
executionTime = time.Now()
|
||||
mu.Unlock()
|
||||
}
|
||||
|
||||
task := CreateRecurringTaskFromNextIntervalTime(TASK_NAME, testFunc, TASK_TIME)
|
||||
defer task.Cancel()
|
||||
|
||||
time.Sleep(TASK_TIME)
|
||||
mu.Lock()
|
||||
expectedSeconds := executionTime.Second()
|
||||
mu.Unlock()
|
||||
assert.EqualValues(t, 0, expectedSeconds%2)
|
||||
|
||||
time.Sleep(TASK_TIME)
|
||||
mu.Lock()
|
||||
expectedSeconds = executionTime.Second()
|
||||
mu.Unlock()
|
||||
assert.EqualValues(t, 0, expectedSeconds%2)
|
||||
|
||||
assert.Equal(t, TASK_NAME, task.Name)
|
||||
assert.Equal(t, TASK_TIME, task.Interval)
|
||||
assert.True(t, task.Recurring)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user