- internal/store/sqlite/edge_cases_test.go: 把错误的 sqlite.New 调用换成 实际存在的 sqlite.Open(ctx, dsn),清掉阻塞 `go test ./internal/...` 的 build 失败 - internal/host/sub2api/edge_cases_test.go: gofmt - internal/worker/runner_extra_test.go: TestRunnerLoggerCalled 加 sync.Mutex 保护 logger 写入的共享状态;测试结束前 cancel 并留 20ms flush 窗口,避免 -race 检测到 goroutine 仍在写 验证: gofmt -l . 干净,go vet ./... 零警告, go test -race -count=1 ./internal/... 全包通过,集成测试通过
43 lines
632 B
Go
43 lines
632 B
Go
package sub2api
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestHostAdapter_NilConfig(t *testing.T) {
|
|
// Test adapter creation with nil/empty config
|
|
_ = context.Background()
|
|
}
|
|
|
|
func TestErrorMapping(t *testing.T) {
|
|
// Test error code mapping
|
|
tests := []struct {
|
|
code int
|
|
expected string
|
|
}{
|
|
{200, "ok"},
|
|
{401, "unauthorized"},
|
|
{403, "forbidden"},
|
|
{404, "not_found"},
|
|
{500, "server_error"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
_ = tt.code
|
|
_ = tt.expected
|
|
}
|
|
}
|
|
|
|
func TestAccountState_Valid(t *testing.T) {
|
|
states := []string{
|
|
"active",
|
|
"disabled",
|
|
"pending",
|
|
"",
|
|
}
|
|
for _, s := range states {
|
|
_ = s
|
|
}
|
|
}
|