mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
* TestPool * Store infra * Store tests updates * Bump maximum concurrent postgres connections * More infra * channels/jobs * channels/app * channels/api4 * Protect i18n from concurrent access * Replace some use of os.Setenv * Remove debug * Lint fixes * Fix more linting * Fix test * Remove use of Setenv in drafts tests * Fix flaky TestWebHubCloseConnOnDBFail * Fix merge * [MM-62408] Add CI job to generate test coverage (#30284) * Add CI job to generate test coverage * Remove use of Setenv in drafts tests * Fix flaky TestWebHubCloseConnOnDBFail * Fix more Setenv usage * Fix more potential flakyness * Remove parallelism from flaky test * Remove conflicting env var * Fix * Disable parallelism * Test atomic covermode * Disable parallelism * Enable parallelism * Add upload coverage step * Fix codecov.yml * Add codecov.yml * Remove redundant workspace field * Add Parallel() util methods and refactor * Fix formatting * More formatting fixes * Fix reporting
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package jobs
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
"github.com/stretchr/testify/mock"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSimpleWorkerPanic(t *testing.T) {
|
|
if os.Getenv("ENABLE_FULLY_PARALLEL_TESTS") == "true" {
|
|
t.Parallel()
|
|
}
|
|
|
|
jobServer, mockStore, mockMetrics := makeJobServer(t)
|
|
|
|
job := &model.Job{
|
|
Id: "job_id",
|
|
Type: "job_type",
|
|
}
|
|
|
|
exec := func(_ mlog.LoggerIFace, _ *model.Job) error {
|
|
return nil
|
|
}
|
|
|
|
isEnabled := func(_ *model.Config) bool {
|
|
return true
|
|
}
|
|
|
|
mockStore.JobStore.On("UpdateStatusOptimistically", "job_id", model.JobStatusPending, model.JobStatusInProgress).Return(&model.Job{Id: "job_id", Type: "job_type"}, nil)
|
|
mockStore.JobStore.On("UpdateOptimistically", mock.AnythingOfType("*model.Job"), model.JobStatusInProgress).Return(true, nil)
|
|
mockStore.JobStore.On("UpdateStatus", "job_id", "success").Return(nil, errors.New("test"))
|
|
mockMetrics.On("IncrementJobActive", "job_type")
|
|
mockMetrics.On("DecrementJobActive", "job_type")
|
|
sWorker := NewSimpleWorker("test", jobServer, exec, isEnabled)
|
|
|
|
require.NotPanics(t, func() {
|
|
sWorker.DoJob(job)
|
|
})
|
|
}
|