!96 删除数据库备份和恢复历史

* feat: 删除数据库备份历史
* refactor dbScheduler
* feat: 从数据库备份历史中恢复数据库
* feat: 删除数据库恢复历史记录
* refactor dbScheuler
This commit is contained in:
kanzihuang
2024-01-30 13:12:43 +00:00
committed by Coder慌
parent fc1b9ef35d
commit 3f828cc5b0
33 changed files with 1101 additions and 378 deletions

View File

@@ -29,14 +29,19 @@ func (t *testJob) GetKey() JobKey {
return t.Key
}
func (t *testJob) SetStatus(status JobStatus, err error) {}
func (t *testJob) SetEnabled(enabled bool, desc string) {}
func TestRunner_Close(t *testing.T) {
signal := make(chan struct{}, 1)
waiting := sync.WaitGroup{}
waiting.Add(1)
runner := NewRunner[*testJob](1, func(ctx context.Context, job *testJob) {
runner := NewRunner[*testJob](1, func(ctx context.Context, job *testJob) error {
waiting.Done()
timex.SleepWithContext(ctx, time.Hour)
signal <- struct{}{}
return nil
})
go func() {
job := &testJob{
@@ -78,8 +83,9 @@ func TestRunner_AddJob(t *testing.T) {
want: ErrJobExist,
},
}
runner := NewRunner[*testJob](1, func(ctx context.Context, job *testJob) {
runner := NewRunner[*testJob](1, func(ctx context.Context, job *testJob) error {
timex.SleepWithContext(ctx, time.Hour)
return nil
})
defer runner.Close()
for _, tc := range testCases {
@@ -99,10 +105,11 @@ func TestJob_UpdateStatus(t *testing.T) {
running
finished
)
runner := NewRunner[*testJob](1, func(ctx context.Context, job *testJob) {
runner := NewRunner[*testJob](1, func(ctx context.Context, job *testJob) error {
job.status = running
timex.SleepWithContext(ctx, d*2)
job.status = finished
return nil
})
first := newTestJob("first")
second := newTestJob("second")