Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/runtime/tasks/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ func actionToHostStatus(action agentapi.HostAction) string {
return "stopped"
case agentapi.ActionRebuildHost:
return "running"
case agentapi.ActionPrepareHost:
return ""
case agentapi.ActionReloadHostBypass:
return "" // 不改变 host 状态
default:
Expand Down
30 changes: 30 additions & 0 deletions internal/runtime/tasks/worker_status_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package tasks

import (
"testing"

"github.com/zanel1u/cloud-cli-proxy/internal/agentapi"
)

func TestActionToHostStatusPrepareHostDoesNotChangeStatus(t *testing.T) {
tests := []struct {
name string
action agentapi.HostAction
want string
}{
{name: "create", action: agentapi.ActionCreateHost, want: "running"},
{name: "start", action: agentapi.ActionStartHost, want: "running"},
{name: "rebuild", action: agentapi.ActionRebuildHost, want: "running"},
{name: "stop", action: agentapi.ActionStopHost, want: "stopped"},
{name: "prepare host", action: agentapi.ActionPrepareHost, want: ""},
{name: "reload bypass", action: agentapi.ActionReloadHostBypass, want: ""},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := actionToHostStatus(tt.action); got != tt.want {
t.Fatalf("actionToHostStatus(%q) = %q, want %q", tt.action, got, tt.want)
}
})
}
}
Loading