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
1 change: 1 addition & 0 deletions server/cmd/multica/cmd_autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ func runAutopilotUpdate(cmd *cobra.Command, args []string) error {
if resolveErr != nil {
return fmt.Errorf("resolve agent: %w", resolveErr)
}
body["assignee_type"] = "agent"
body["assignee_id"] = agentID
}
if cmd.Flags().Changed("project") {
Expand Down
50 changes: 50 additions & 0 deletions server/cmd/multica/cmd_autopilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,56 @@ func TestRunAutopilotUpdateSendsProjectIDChanges(t *testing.T) {
})
}

func TestRunAutopilotUpdateAgentSwitchesAssigneeType(t *testing.T) {
const (
autopilotID = "33333333-3333-3333-3333-333333333333"
agentID = "11111111-1111-1111-1111-111111111111"
)

var body map[string]any
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/api/agents":
json.NewEncoder(w).Encode([]map[string]any{{"id": agentID, "name": "Codex Agent"}})
case "/api/autopilots/" + autopilotID:
if r.Method != http.MethodPatch {
t.Errorf("method = %s, want PATCH", r.Method)
}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
t.Errorf("decode body: %v", err)
}
if body["assignee_type"] != "agent" {
http.Error(w, "squad not found", http.StatusBadRequest)
return
}
json.NewEncoder(w).Encode(map[string]any{
"id": autopilotID,
"assignee_type": body["assignee_type"],
"assignee_id": body["assignee_id"],
})
default:
http.NotFound(w, r)
}
}))
defer srv.Close()

t.Setenv("MULTICA_SERVER_URL", srv.URL)
t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")
t.Setenv("MULTICA_TOKEN", "mat_test-token")

cmd := newAutopilotUpdateTestCmd()
_ = cmd.Flags().Set("agent", "Codex Agent")
if err := runAutopilotUpdate(cmd, []string{autopilotID}); err != nil {
t.Fatalf("runAutopilotUpdate: %v", err)
}
if got := body["assignee_id"]; got != agentID {
t.Fatalf("assignee_id = %#v, want %q", got, agentID)
}
if got := body["assignee_type"]; got != "agent" {
t.Fatalf("assignee_type = %#v, want agent", got)
}
}

func TestRunAutopilotUpdateSendsSubscriberReplacement(t *testing.T) {
const (
autopilotID = "33333333-3333-3333-3333-333333333333"
Expand Down
Loading