style(handler,server): 格式化测试代码结构体字段对齐

- 对齐 errorpage_test.go、static_test.go、pprof_test.go 中的结构体字段
- 纯代码格式化,无逻辑变更

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
xfy 2026-04-08 13:24:36 +08:00
parent 3711b12fad
commit b72394eb3b
3 changed files with 41 additions and 41 deletions

View File

@ -295,11 +295,11 @@ func TestErrorPageManager_GetPage(t *testing.T) {
}
tests := []struct {
name string
cfg config.ErrorPageConfig
requestCode int
wantContent string
wantFound bool
name string
cfg config.ErrorPageConfig
requestCode int
wantContent string
wantFound bool
wantResponseCode int
}{
{

View File

@ -585,11 +585,11 @@ func TestStaticHandler_Handle_Symlink(t *testing.T) {
// TestStaticHandler_SetTryFiles 测试 SetTryFiles 配置设置
func TestStaticHandler_SetTryFiles(t *testing.T) {
tests := []struct {
name string
tryFiles []string
tryFilesPass bool
wantTryFiles []string
wantPass bool
name string
tryFiles []string
tryFilesPass bool
wantTryFiles []string
wantPass bool
}{
{
name: "基本配置",
@ -842,14 +842,14 @@ func TestStaticHandler_handleTryFiles(t *testing.T) {
// TestStaticHandler_handleInternalRedirect 测试内部重定向功能
func TestStaticHandler_handleInternalRedirect(t *testing.T) {
tests := []struct {
name string
setup func(t *testing.T, root string)
tryFiles []string
name string
setup func(t *testing.T, root string)
tryFiles []string
tryFilesPass bool
path string
wantStatus int
wantContent string
skipContent bool
path string
wantStatus int
wantContent string
skipContent bool
}{
{
name: "tryFilesPass false 直接服务文件",

View File

@ -272,59 +272,59 @@ func TestPprofHandler_Path(t *testing.T) {
func TestPprofHandler_isAllowed(t *testing.T) {
tests := []struct {
name string
allowedIPs []string
name string
allowedIPs []string
allowedNets []string
clientIP string
clientIP string
wantAllowed bool
}{
{
name: "empty allow list - allow all",
allowedIPs: []string{},
name: "empty allow list - allow all",
allowedIPs: []string{},
allowedNets: []string{},
clientIP: "192.168.1.100",
clientIP: "192.168.1.100",
wantAllowed: true,
},
{
name: "IP exact match",
allowedIPs: []string{"127.0.0.1"},
name: "IP exact match",
allowedIPs: []string{"127.0.0.1"},
allowedNets: []string{},
clientIP: "127.0.0.1",
clientIP: "127.0.0.1",
wantAllowed: true,
},
{
name: "IP no match",
allowedIPs: []string{"127.0.0.1"},
name: "IP no match",
allowedIPs: []string{"127.0.0.1"},
allowedNets: []string{},
clientIP: "127.0.0.2",
clientIP: "127.0.0.2",
wantAllowed: false,
},
{
name: "CIDR match",
allowedIPs: []string{},
name: "CIDR match",
allowedIPs: []string{},
allowedNets: []string{"192.168.0.0/16"},
clientIP: "192.168.1.100",
clientIP: "192.168.1.100",
wantAllowed: true,
},
{
name: "CIDR no match",
allowedIPs: []string{},
name: "CIDR no match",
allowedIPs: []string{},
allowedNets: []string{"10.0.0.0/8"},
clientIP: "192.168.1.100",
clientIP: "192.168.1.100",
wantAllowed: false,
},
{
name: "IPv6 CIDR match",
allowedIPs: []string{},
name: "IPv6 CIDR match",
allowedIPs: []string{},
allowedNets: []string{"2001:db8::/32"},
clientIP: "2001:db8::1",
clientIP: "2001:db8::1",
wantAllowed: true,
},
{
name: "IPv6 exact match",
allowedIPs: []string{"::1"},
name: "IPv6 exact match",
allowedIPs: []string{"::1"},
allowedNets: []string{},
clientIP: "::1",
clientIP: "::1",
wantAllowed: true,
},
}