Files
OpenFlare/backend/plugins/drivers/driver_inproc_cron/plugin_test.go
T
ryan 528240026d chore(lint): unify formatting on golangci-lint fmt (gofumpt), uncap issue reporting, fix gofumpt drift
- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯
- .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化)
- 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
2026-08-28 16:31:53 +08:00

43 lines
1.0 KiB
Go

// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package driver_inproc_cron_test
import (
"Wavelet/core"
"Wavelet/plugins/drivers/driver_inproc_cron"
"context"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestInprocCronPlugin(t *testing.T) {
ctx := core.NewContext(context.Background())
cronPlugin := driver_inproc_cron.New()
assert.Equal(t, "driver_inproc_cron", cronPlugin.Name())
assert.Equal(t, core.DriverTypeScheduler, cronPlugin.Type())
require.NoError(t, cronPlugin.Apply(ctx))
var cronTriggered atomic.Int32
ctx.Tasks().Register("cron:heartbeat", func(ctx context.Context) error {
cronTriggered.Add(1)
return nil
})
// Every second cron spec
ctx.Schedules().RegisterCron("* * * * * *", "cron:heartbeat", nil)
require.NoError(t, cronPlugin.Start(context.Background()))
require.Eventually(t, func() bool {
return cronTriggered.Load() >= 1
}, 3*time.Second, 100*time.Millisecond)
require.NoError(t, cronPlugin.Stop(context.Background()))
}