feat(release):完成双 release 运维闭环
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

This commit is contained in:
2026-09-12 11:08:04 +08:00
parent 8a77502272
commit 8d57a63697
27 changed files with 3635 additions and 222 deletions
+49
View File
@@ -88,6 +88,55 @@ func TestResourceRepairQueuesTask(t *testing.T) {
}
}
func TestReleaseDistributionUsesTypedRPCContract(t *testing.T) {
client := newTestClient(t, func(t *testing.T, req testRequest) testResponse {
if req.Method != "release.distribution" {
t.Fatalf("method = %s", req.Method)
}
var params ReleaseDistributionParams
if err := json.Unmarshal(req.Params, &params); err != nil {
t.Fatalf("decode params: %v", err)
}
if params.Channel != "localized" || params.ReleaseID != "localized-1" || params.Offset != 2 || params.Limit != 10 {
t.Fatalf("params = %#v", params)
}
return testResponse{
Result: testEnvelope{
OK: true,
Status: "ok",
Data: map[string]any{
"available": true,
"channel": "localized",
"release_id": "localized-1",
"resource_root": "/tmp/localized",
"total": 3,
"offset": 2,
"limit": 10,
"entries": []any{map[string]any{
"url": "https://example.invalid/data.bin",
"destination": "host/data.bin",
"bytes": 4,
"blake3": "abcd",
}},
},
},
}
})
page, err := client.ReleaseDistribution(context.Background(), ReleaseDistributionParams{
Channel: "localized",
ReleaseID: "localized-1",
Offset: 2,
Limit: 10,
})
if err != nil {
t.Fatalf("ReleaseDistribution error: %v", err)
}
if !page.Available || page.ResourceRoot != "/tmp/localized" || len(page.Entries) != 1 {
t.Fatalf("page = %#v", page)
}
}
func TestDaemonRestartSendsControlMethod(t *testing.T) {
client := newTestClient(t, func(t *testing.T, req testRequest) testResponse {
if req.Method != "daemon.restart" {