mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 07:36:37 +08:00
[优化] 接口优化, 心跳请求返回规则摘要
This commit is contained in:
@@ -78,6 +78,17 @@ func TestHeartbeatNodeReturnsPreviewUpdateSettings(t *testing.T) {
|
||||
if err := node.Insert(); err != nil {
|
||||
t.Fatalf("failed to seed node: %v", err)
|
||||
}
|
||||
if err := model.DB.Create(&model.ConfigVersion{
|
||||
Version: "20260313-001",
|
||||
SnapshotJSON: "{}",
|
||||
MainConfig: "worker_processes auto;",
|
||||
RenderedConfig: "server { listen 80; }",
|
||||
Checksum: "checksum-active-1",
|
||||
IsActive: true,
|
||||
CreatedBy: "root",
|
||||
}).Error; err != nil {
|
||||
t.Fatalf("failed to seed active config version: %v", err)
|
||||
}
|
||||
|
||||
resp, err := HeartbeatNode(node, AgentNodePayload{
|
||||
NodeID: node.NodeID,
|
||||
@@ -94,6 +105,12 @@ func TestHeartbeatNodeReturnsPreviewUpdateSettings(t *testing.T) {
|
||||
if resp.AgentSettings == nil {
|
||||
t.Fatal("expected agent settings in heartbeat response")
|
||||
}
|
||||
if resp.ActiveConfig == nil {
|
||||
t.Fatal("expected active config summary in heartbeat response")
|
||||
}
|
||||
if resp.ActiveConfig.Version == "" || resp.ActiveConfig.Checksum == "" {
|
||||
t.Fatal("expected active config summary to include version and checksum")
|
||||
}
|
||||
if !resp.AgentSettings.UpdateNow {
|
||||
t.Fatal("expected update_now to be true")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user