docs(agent): 统一中文注释并补充部署文档
将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、 示例配置,并完善构建脚本对 VERSION 注入的说明。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,18 +14,18 @@ import (
|
||||
"mfd-monitor-agent/internal/status"
|
||||
)
|
||||
|
||||
// StaticProvider is a test provider with a fixed cached snapshot.
|
||||
// StaticProvider 是用于测试的固定缓存快照提供者。
|
||||
type StaticProvider struct {
|
||||
Snapshot status.HostStatus
|
||||
OK bool
|
||||
}
|
||||
|
||||
// Get returns the configured static snapshot and readiness flag.
|
||||
// Get 返回配置的静态快照与就绪标志。
|
||||
func (p StaticProvider) Get() (status.HostStatus, bool) {
|
||||
return p.Snapshot, p.OK
|
||||
}
|
||||
|
||||
// TestReportPostsHostStatusJSON verifies reports reuse the HostStatus JSON payload.
|
||||
// TestReportPostsHostStatusJSON 验证上报复用 HostStatus JSON 载荷。
|
||||
func TestReportPostsHostStatusJSON(t *testing.T) {
|
||||
var got status.HostStatus
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -52,7 +52,7 @@ func TestReportPostsHostStatusJSON(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestReportReturnsErrorForHTTPFailure verifies non-2xx responses fail one report.
|
||||
// TestReportReturnsErrorForHTTPFailure 验证非 2xx 响应导致单次上报失败。
|
||||
func TestReportReturnsErrorForHTTPFailure(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
@@ -65,7 +65,7 @@ func TestReportReturnsErrorForHTTPFailure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunRetriesFailedReportOnce verifies the loop retries one failed report.
|
||||
// TestRunRetriesFailedReportOnce 验证循环对失败上报重试一次。
|
||||
func TestRunRetriesFailedReportOnce(t *testing.T) {
|
||||
var requests atomic.Int32
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
@@ -99,7 +99,7 @@ func TestRunRetriesFailedReportOnce(t *testing.T) {
|
||||
<-done
|
||||
}
|
||||
|
||||
// TestRunStopsDuringRetryDelayWhenContextCanceled verifies retry waits honor cancellation.
|
||||
// TestRunStopsDuringRetryDelayWhenContextCanceled 验证重试等待可被 ctx 取消。
|
||||
func TestRunStopsDuringRetryDelayWhenContextCanceled(t *testing.T) {
|
||||
var requests atomic.Int32
|
||||
firstRequest := make(chan struct{})
|
||||
|
||||
Reference in New Issue
Block a user