MM-27449: Compliance Jobs rerun after warning status (#15178)
* add warning as success result * revert config changes * add unit test, update unit test * add a couple more tests * update store layers Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d48eec6727
Коммит
0302e0f477
@@ -21,6 +21,7 @@ func TestJobStore(t *testing.T, ss store.Store) {
|
||||
t.Run("JobGetAllPage", func(t *testing.T) { testJobGetAllPage(t, ss) })
|
||||
t.Run("JobGetAllByStatus", func(t *testing.T) { testJobGetAllByStatus(t, ss) })
|
||||
t.Run("GetNewestJobByStatusAndType", func(t *testing.T) { testJobStoreGetNewestJobByStatusAndType(t, ss) })
|
||||
t.Run("GetNewestJobByStatusesAndType", func(t *testing.T) { testJobStoreGetNewestJobByStatusesAndType(t, ss) })
|
||||
t.Run("GetCountByStatusAndType", func(t *testing.T) { testJobStoreGetCountByStatusAndType(t, ss) })
|
||||
t.Run("JobUpdateOptimistically", func(t *testing.T) { testJobUpdateOptimistically(t, ss) })
|
||||
t.Run("JobUpdateStatusUpdateStatusOptimistically", func(t *testing.T) { testJobUpdateStatusUpdateStatusOptimistically(t, ss) })
|
||||
@@ -261,6 +262,66 @@ func testJobStoreGetNewestJobByStatusAndType(t *testing.T, ss store.Store) {
|
||||
assert.Nil(t, received)
|
||||
}
|
||||
|
||||
func testJobStoreGetNewestJobByStatusesAndType(t *testing.T, ss store.Store) {
|
||||
jobType1 := model.NewId()
|
||||
jobType2 := model.NewId()
|
||||
status1 := model.NewId()
|
||||
status2 := model.NewId()
|
||||
|
||||
jobs := []*model.Job{
|
||||
{
|
||||
Id: model.NewId(),
|
||||
Type: jobType1,
|
||||
CreateAt: 1001,
|
||||
Status: status1,
|
||||
},
|
||||
{
|
||||
Id: model.NewId(),
|
||||
Type: jobType1,
|
||||
CreateAt: 1000,
|
||||
Status: status1,
|
||||
},
|
||||
{
|
||||
Id: model.NewId(),
|
||||
Type: jobType2,
|
||||
CreateAt: 1003,
|
||||
Status: status1,
|
||||
},
|
||||
{
|
||||
Id: model.NewId(),
|
||||
Type: jobType1,
|
||||
CreateAt: 1004,
|
||||
Status: status2,
|
||||
},
|
||||
}
|
||||
|
||||
for _, job := range jobs {
|
||||
_, err := ss.Job().Save(job)
|
||||
require.Nil(t, err)
|
||||
defer ss.Job().Delete(job.Id)
|
||||
}
|
||||
|
||||
received, err := ss.Job().GetNewestJobByStatusesAndType([]string{status1, status2}, jobType1)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, jobs[3].Id, received.Id)
|
||||
|
||||
received, err = ss.Job().GetNewestJobByStatusesAndType([]string{model.NewId(), model.NewId()}, model.NewId())
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, received)
|
||||
|
||||
received, err = ss.Job().GetNewestJobByStatusesAndType([]string{status2}, jobType2)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, received)
|
||||
|
||||
received, err = ss.Job().GetNewestJobByStatusesAndType([]string{status1}, jobType2)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, jobs[2].Id, received.Id)
|
||||
|
||||
received, err = ss.Job().GetNewestJobByStatusesAndType([]string{}, jobType1)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, received)
|
||||
}
|
||||
|
||||
func testJobStoreGetCountByStatusAndType(t *testing.T, ss store.Store) {
|
||||
jobType1 := model.NewId()
|
||||
jobType2 := model.NewId()
|
||||
|
||||
@@ -210,6 +210,31 @@ func (_m *JobStore) GetNewestJobByStatusAndType(status string, jobType string) (
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetNewestJobByStatusesAndType provides a mock function with given fields: statuses, jobType
|
||||
func (_m *JobStore) GetNewestJobByStatusesAndType(statuses []string, jobType string) (*model.Job, *model.AppError) {
|
||||
ret := _m.Called(statuses, jobType)
|
||||
|
||||
var r0 *model.Job
|
||||
if rf, ok := ret.Get(0).(func([]string, string) *model.Job); ok {
|
||||
r0 = rf(statuses, jobType)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Job)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func([]string, string) *model.AppError); ok {
|
||||
r1 = rf(statuses, jobType)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: job
|
||||
func (_m *JobStore) Save(job *model.Job) (*model.Job, *model.AppError) {
|
||||
ret := _m.Called(job)
|
||||
|
||||
Ссылка в новой задаче
Block a user