Skip to content

Conversation

@KirCute
Copy link
Member

@KirCute KirCute commented Dec 11, 2025

Description / 描述

蓝奏云优享版计算总容量增加vipSize

Motivation and Context / 背景

How Has This Been Tested? / 测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

Copy link
Member

@xrgzs xrgzs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试没问题,能将 null 解析成 0

package template

import (
	"testing"

	"github.com/OpenListTeam/OpenList/v4/pkg/utils"
)

func TestJP(t *testing.T) {
	jsonStr := `{"map": {"vipSize": null}}`

	val := utils.Json.Get([]byte(jsonStr), "map", "vipSize").ToUint64()
	t.Logf("解析结果:%d (类型:%T)\n", val, val)

	// must be 0
	if val != 0 {
		t.Errorf("期望值 0,实际值 %d", val)
	}
}
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestJP$ github.com/OpenListTeam/OpenList/v4/drivers/ilanzou

=== RUN   TestJP
    /Users/x/project/OpenList/drivers/ilanzou/util_test.go:13: 解析结果:0 (类型:uint64)
--- PASS: TestJP (0.00s)
PASS
ok      github.com/OpenListTeam/OpenList/v4/drivers/ilanzou     (cached)

@xrgzs xrgzs merged commit 1fc9c83 into OpenListTeam:main Dec 12, 2025
7 of 14 checks passed
@KirCute
Copy link
Member Author

KirCute commented Dec 12, 2025

测试没问题,能将 null 解析成 0

package template

import (
	"testing"

	"github.com/OpenListTeam/OpenList/v4/pkg/utils"
)

func TestJP(t *testing.T) {
	jsonStr := `{"map": {"vipSize": null}}`

	val := utils.Json.Get([]byte(jsonStr), "map", "vipSize").ToUint64()
	t.Logf("解析结果:%d (类型:%T)\n", val, val)

	// must be 0
	if val != 0 {
		t.Errorf("期望值 0,实际值 %d", val)
	}
}
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestJP$ github.com/OpenListTeam/OpenList/v4/drivers/ilanzou

=== RUN   TestJP
    /Users/x/project/OpenList/drivers/ilanzou/util_test.go:13: 解析结果:0 (类型:uint64)
--- PASS: TestJP (0.00s)
PASS
ok      github.com/OpenListTeam/OpenList/v4/drivers/ilanzou     (cached)

能不能把vipSize不存在的情况解析为0

@xrgzs
Copy link
Member

xrgzs commented Dec 12, 2025

能不能把vipSize不存在的情况解析为0

试了下没问题

func TestNotExist(t *testing.T) {
	jsonStr := `{"map": {"vipSize2": null}}`

	val := utils.Json.Get([]byte(jsonStr), "map", "vipSize").ToUint64()
	t.Logf("解析结果:%d (类型:%T)\n", val, val)

	// must be 0
	if val != 0 {
		t.Errorf("期望值 0,实际值 %d", val)
	}
}
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestNotExist$ github.com/OpenListTeam/OpenList/v4/drivers/ilanzou

=== RUN   TestNotExist
    /Users/x/project/OpenList/drivers/ilanzou/util_test.go:25: 解析结果:0 (类型:uint64)
--- PASS: TestNotExist (0.00s)
PASS
ok      github.com/OpenListTeam/OpenList/v4/drivers/ilanzou     0.208s

@KirCute KirCute deleted the fix/ilanzou-vip-quota branch December 12, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants