fix(ci): 修复adminreset单测长临时路径导致bind失败并配置Go缓存依赖路径
Some checks are pending
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-10-18 11:14:55 +08:00
parent ab6828941b
commit 45e8521aef
3 changed files with 19 additions and 1 deletions

View File

@ -38,6 +38,7 @@ jobs:
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff
with:
go-version: '1.26.6'
cache-dependency-path: backend/go.sum
- name: Gen output name
run: |
archive_extension="tar.gz"
@ -92,6 +93,7 @@ jobs:
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff
with:
go-version: '1.26.6'
cache-dependency-path: backend/go.sum
- name: Setup Node.js for test runner
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:

View File

@ -25,6 +25,7 @@ jobs:
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff
with:
go-version: '1.26.6'
cache-dependency-path: backend/go.sum
- name: Setup Node.js for test runner
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:

View File

@ -2,6 +2,7 @@ package adminreset
import (
"context"
"os"
"path/filepath"
"testing"
"time"
@ -152,10 +153,24 @@ func TestResetSuperAdminRejectsMissingTarget(t *testing.T) {
}
}
func testResetControlSocketDir(t *testing.T) string {
t.Helper()
dir := t.TempDir()
if len(dir)+len("/control.sock") >= 90 {
shortDir, err := os.MkdirTemp("/tmp", "smail-*")
if err == nil {
t.Cleanup(func() { _ = os.RemoveAll(shortDir) })
return shortDir
}
}
return dir
}
func TestControlServerInterfaceCompiles(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
if _, err := ListenControl(filepath.Join(t.TempDir(), "control.sock"), []uint32{0}); err == nil {
socketPath := filepath.Join(testResetControlSocketDir(t), "control.sock")
if _, err := ListenControl(socketPath, []uint32{0}); err == nil {
// 具体平台实现由各自适配器测试覆盖。
}
_ = ctx