更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -5,8 +5,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestFallbackCovers2026 校验内置兜底数据与国务院办公厅 2026 年通知一致。
|
||||
// 这里的期望值直接抄自官方通知,属于"事实断言":一旦有人改错数据即失败。
|
||||
func TestFallbackCovers2026(t *testing.T) {
|
||||
got := builtinByYear(2026)
|
||||
if len(got) == 0 {
|
||||
@@ -18,7 +16,6 @@ func TestFallbackCovers2026(t *testing.T) {
|
||||
byDate[d.Date] = d
|
||||
}
|
||||
|
||||
// 元旦 1/1-1/3 放假;1/4 上班
|
||||
for _, d := range []string{"2026-01-01", "2026-01-02", "2026-01-03"} {
|
||||
if v, ok := byDate[d]; !ok || v.Type != TypeHoliday {
|
||||
t.Errorf("%s 应为放假日,实际 %+v", d, v)
|
||||
@@ -28,7 +25,6 @@ func TestFallbackCovers2026(t *testing.T) {
|
||||
t.Errorf("2026-01-04 应为调休上班日,实际 %+v", v)
|
||||
}
|
||||
|
||||
// 春节 2/15-2/23 放假,共 9 天;2/14、2/28 上班
|
||||
springCount := 0
|
||||
for _, d := range got {
|
||||
if d.Type == TypeHoliday && d.Name == "春节" {
|
||||
@@ -44,7 +40,6 @@ func TestFallbackCovers2026(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// 国庆 10/1-10/7 放假;9/20、10/10 上班
|
||||
nationalCount := 0
|
||||
for _, d := range got {
|
||||
if d.Type == TypeHoliday && d.Name == "国庆节" {
|
||||
@@ -60,7 +55,6 @@ func TestFallbackCovers2026(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// 中秋 9/25-9/27、端午 6/19-6/21、清明 4/4-4/6、劳动节 5/1-5/5
|
||||
cases := []struct {
|
||||
name string
|
||||
start string
|
||||
@@ -87,7 +81,6 @@ func TestFallbackCovers2026(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestFallbackAllYears 校验三年内置数据都能被索引到,且每年都有调休上班日。
|
||||
func TestFallbackAllYears(t *testing.T) {
|
||||
for _, y := range Years() {
|
||||
list := builtinByYear(y)
|
||||
@@ -108,7 +101,6 @@ func TestFallbackAllYears(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAnnotateWage 校验薪资倍数标注:春节前 3 天三薪,其余两薪。
|
||||
func TestAnnotateWage(t *testing.T) {
|
||||
list := []Day{
|
||||
{Date: "2026-02-15", Name: "春节", Type: TypeHoliday},
|
||||
@@ -126,7 +118,6 @@ func TestAnnotateWage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestExpandRange 校验日期区间展开。
|
||||
func TestExpandRange(t *testing.T) {
|
||||
got := expandRange("2026-02-15", "2026-02-23")
|
||||
if len(got) != 9 {
|
||||
@@ -135,21 +126,17 @@ func TestExpandRange(t *testing.T) {
|
||||
if got[0] != "2026-02-15" || got[8] != "2026-02-23" {
|
||||
t.Errorf("区间首尾错误: %v", got)
|
||||
}
|
||||
// 单日
|
||||
if one := expandRange("2026-01-01", ""); len(one) != 1 || one[0] != "2026-01-01" {
|
||||
t.Errorf("单日区间展开错误: %v", one)
|
||||
}
|
||||
// 跨月
|
||||
if cross := expandRange("2026-02-28", "2026-03-02"); len(cross) != 3 {
|
||||
t.Errorf("跨月区间展开错误: %v", cross)
|
||||
}
|
||||
// 异常区间不 panic 且返回空
|
||||
if bad := expandRange("2026-03-01", "2026-02-01"); len(bad) != 0 {
|
||||
t.Errorf("结束早于开始应返回空,实际 %v", bad)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDedupSort 校验同日去重时休假日优先于调休上班日。
|
||||
func TestDedupSort(t *testing.T) {
|
||||
list := []Day{
|
||||
{Date: "2026-05-09", Name: "调休上班", Type: TypeWorkday},
|
||||
@@ -168,14 +155,10 @@ func TestDedupSort(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestFetchYearLive 联网校验真实数据源可用性(仅测"未收录年份"的联网分支)。
|
||||
// 2024-2026 走内置数据不联网,因此这里用 2023 年验证外网拉取能力;
|
||||
// 若外网不可用则跳过,不把 CI 绑死在第三方接口可用性上。
|
||||
func TestFetchYearLive(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("跳过联网测试")
|
||||
}
|
||||
// 2023 未被内置数据收录,必须联网
|
||||
list, src, err := FetchYear(2023)
|
||||
if err != nil {
|
||||
t.Skipf("外网不可用,跳过联网测试: %v", err)
|
||||
@@ -189,9 +172,6 @@ func TestFetchYearLive(t *testing.T) {
|
||||
t.Logf("2023 年数据来源: %s,共 %d 条", src, len(list))
|
||||
}
|
||||
|
||||
// TestBuiltinTakesPriority 校验已收录年份走内置数据、完全不联网。
|
||||
// 这是"日历翻月不卡顿"的核心保证:若哪天有人把网络查询挪到内置判断之前,
|
||||
// 本测试会立即失败。
|
||||
func TestBuiltinTakesPriority(t *testing.T) {
|
||||
for _, y := range []int{2024, 2025, 2026} {
|
||||
list, src, err := FetchYear(y)
|
||||
@@ -207,10 +187,7 @@ func TestBuiltinTakesPriority(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestFetchYearFastForBuiltin 量化验证内置路径的耗时:
|
||||
// 已收录年份必须是纯内存操作(远低于 50ms),而跨境网络请求至少要 300ms。
|
||||
func TestFetchYearFastForBuiltin(t *testing.T) {
|
||||
// 预热,排除首次调用的初始化开销
|
||||
_, _, _ = FetchYear(2026)
|
||||
|
||||
start := time.Now()
|
||||
|
||||
Reference in new issue
Block a user