Files
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

70 lines
2.4 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package scheduled_recap
import (
"testing"
"github.com/hanzoteam/server/server/public/model"
"github.com/hanzoteam/server/server/public/shared/mlog"
"github.com/hanzoteam/server/server/public/shared/request"
"github.com/hanzoteam/server/server/v8/channels/jobs"
"github.com/hanzoteam/server/server/v8/channels/store/storetest"
"github.com/hanzoteam/server/server/v8/channels/utils/testutils"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)
func TestScheduleJobEnqueuesEachDueRecapAndSkipsDuplicateAtomically(t *testing.T) {
cfg := &model.Config{}
cfg.SetDefaults()
cfg.FeatureFlags.EnableAIRecaps = true
mockStore := &storetest.Store{}
t.Cleanup(func() {
mockStore.AssertExpectations(t)
})
jobServer := jobs.NewJobServer(&testutils.StaticConfigService{Cfg: cfg}, mockStore, nil, mlog.CreateConsoleTestLogger(t), nil)
jobServer.RegisterJobType(model.JobTypeScheduledRecap, jobs.NewSimpleWorker(
model.JobTypeScheduledRecap,
jobServer,
func(logger mlog.LoggerIFace, job *model.Job) error { return nil },
func(cfg *model.Config) bool { return true },
), nil)
dueRecap1 := testScheduledRecap(true)
dueRecap2 := testScheduledRecap(true)
duplicateRecap := *dueRecap1
dueRecaps := []*model.ScheduledRecap{dueRecap1, dueRecap2, &duplicateRecap}
mockStore.ScheduledRecapStore.
On("GetDueBefore", mock.AnythingOfType("int64"), 100).
Return(dueRecaps, nil)
for _, sr := range []*model.ScheduledRecap{dueRecap1, dueRecap2} {
mockStore.JobStore.
On("SaveOnceByTypeAndData", mock.MatchedBy(func(job *model.Job) bool {
return job.Type == model.JobTypeScheduledRecap &&
len(job.Data) == 1 &&
job.Data["scheduled_recap_id"] == sr.Id
}), map[string]string{"scheduled_recap_id": sr.Id}).
Return(func(job *model.Job, data map[string]string) *model.Job { return job }, nil).
Once()
}
mockStore.JobStore.
On("SaveOnceByTypeAndData", mock.MatchedBy(func(job *model.Job) bool {
return job.Type == model.JobTypeScheduledRecap &&
job.Data["scheduled_recap_id"] == dueRecap1.Id
}), map[string]string{"scheduled_recap_id": dueRecap1.Id}).
Return(nil, nil).
Once()
scheduler := MakeScheduler(jobServer, mockStore)
job, appErr := scheduler.ScheduleJob(request.EmptyContext(mlog.CreateConsoleTestLogger(t)), cfg, false, nil)
require.Nil(t, appErr)
require.Nil(t, job)
}