mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 08:14:55 +08:00
feat(release):完成双 release 运维闭环
This commit is contained in:
@@ -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, ¶ms); 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" {
|
||||
|
||||
Reference in New Issue
Block a user