mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-15 23:22:59 +08:00
分组用量仓储测试原先固定恢复上海时区,覆盖集成测试包初始化的 UTC,并导致后续今日统计多算。统一保存并恢复测试进入前的时区,避免 unit 和 integration 用例相互污染。
17 lines
387 B
Go
17 lines
387 B
Go
package repository
|
|
|
|
import (
|
|
"testing"
|
|
|
|
appTimezone "github.com/Wei-Shaw/sub2api/internal/pkg/timezone"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func useGroupUsageRepositoryTestTimezone(t *testing.T, name string) {
|
|
t.Helper()
|
|
|
|
previousName := appTimezone.Name()
|
|
require.NoError(t, appTimezone.Init(name))
|
|
t.Cleanup(func() { require.NoError(t, appTimezone.Init(previousName)) })
|
|
}
|