From b72394eb3b221d3e8511596f5067613f329db7ee Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 8 Apr 2026 13:24:36 +0800 Subject: [PATCH] =?UTF-8?q?style(handler,server):=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BD=93=E5=AD=97=E6=AE=B5=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 对齐 errorpage_test.go、static_test.go、pprof_test.go 中的结构体字段 - 纯代码格式化,无逻辑变更 Co-Authored-By: Claude --- internal/handler/errorpage_test.go | 10 +++---- internal/handler/static_test.go | 24 +++++++-------- internal/server/pprof_test.go | 48 +++++++++++++++--------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/internal/handler/errorpage_test.go b/internal/handler/errorpage_test.go index f629f1f..ed2cf2d 100644 --- a/internal/handler/errorpage_test.go +++ b/internal/handler/errorpage_test.go @@ -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 }{ { diff --git a/internal/handler/static_test.go b/internal/handler/static_test.go index a318474..68968e9 100644 --- a/internal/handler/static_test.go +++ b/internal/handler/static_test.go @@ -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 直接服务文件", diff --git a/internal/server/pprof_test.go b/internal/server/pprof_test.go index 090952a..57ad385 100644 --- a/internal/server/pprof_test.go +++ b/internal/server/pprof_test.go @@ -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, }, }