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 { tests := []struct {
name string name string
cfg config.ErrorPageConfig cfg config.ErrorPageConfig
requestCode int requestCode int
wantContent string wantContent string
wantFound bool wantFound bool
wantResponseCode int wantResponseCode int
}{ }{
{ {

View File

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

View File

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