fix: add missing CreatedBy in RPC path
created_by was recently added in c3ef1c3f38 but was missing support for passing in the CreatedBy through the RPC path so a create that was using the daemon was never having the created_by field set.
This commit is contained in:
@@ -223,6 +223,7 @@ var createCmd = &cobra.Command{
|
||||
WaitsFor: waitsFor,
|
||||
WaitsForGate: waitsForGate,
|
||||
Wisp: wisp,
|
||||
CreatedBy: getActorWithGit(),
|
||||
}
|
||||
|
||||
resp, err := daemonClient.Create(createArgs)
|
||||
|
||||
@@ -93,7 +93,8 @@ type CreateArgs struct {
|
||||
Wisp bool `json:"wisp,omitempty"` // Wisp = ephemeral vapor from the Steam Engine; bulk-deleted when closed
|
||||
RepliesTo string `json:"replies_to,omitempty"` // Issue ID for conversation threading
|
||||
// ID generation (bd-hobo)
|
||||
IDPrefix string `json:"id_prefix,omitempty"` // Override prefix for ID generation (mol, wisp, etc.)
|
||||
IDPrefix string `json:"id_prefix,omitempty"` // Override prefix for ID generation (mol, wisp, etc.)
|
||||
CreatedBy string `json:"created_by,omitempty"` // Who created the issue
|
||||
}
|
||||
|
||||
// UpdateArgs represents arguments for the update operation
|
||||
|
||||
@@ -180,7 +180,8 @@ func (s *Server) handleCreate(req *Request) Response {
|
||||
Wisp: createArgs.Wisp,
|
||||
// NOTE: RepliesTo now handled via replies-to dependency (Decision 004)
|
||||
// ID generation (bd-hobo)
|
||||
IDPrefix: createArgs.IDPrefix,
|
||||
IDPrefix: createArgs.IDPrefix,
|
||||
CreatedBy: createArgs.CreatedBy,
|
||||
}
|
||||
|
||||
// Check if any dependencies are discovered-from type
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -9,6 +10,49 @@ import (
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// TestHandleCreate_SetsCreatedBy verifies that CreatedBy is passed through RPC and stored (GH#748)
|
||||
func TestHandleCreate_SetsCreatedBy(t *testing.T) {
|
||||
store := memory.New("/tmp/test.jsonl")
|
||||
server := NewServer("/tmp/test.sock", store, "/tmp", "/tmp/test.db")
|
||||
|
||||
createArgs := CreateArgs{
|
||||
Title: "Test CreatedBy Field",
|
||||
IssueType: "task",
|
||||
Priority: 2,
|
||||
CreatedBy: "test-actor",
|
||||
}
|
||||
createJSON, _ := json.Marshal(createArgs)
|
||||
createReq := &Request{
|
||||
Operation: OpCreate,
|
||||
Args: createJSON,
|
||||
Actor: "test-actor",
|
||||
}
|
||||
|
||||
resp := server.handleCreate(createReq)
|
||||
if !resp.Success {
|
||||
t.Fatalf("create failed: %s", resp.Error)
|
||||
}
|
||||
|
||||
var createdIssue types.Issue
|
||||
if err := json.Unmarshal(resp.Data, &createdIssue); err != nil {
|
||||
t.Fatalf("failed to parse response: %v", err)
|
||||
}
|
||||
|
||||
// Verify CreatedBy was set in the response
|
||||
if createdIssue.CreatedBy != "test-actor" {
|
||||
t.Errorf("expected CreatedBy 'test-actor' in response, got %q", createdIssue.CreatedBy)
|
||||
}
|
||||
|
||||
// Verify CreatedBy was persisted to storage
|
||||
storedIssue, err := store.GetIssue(context.Background(), createdIssue.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get issue from storage: %v", err)
|
||||
}
|
||||
if storedIssue.CreatedBy != "test-actor" {
|
||||
t.Errorf("expected CreatedBy 'test-actor' in storage, got %q", storedIssue.CreatedBy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmitMutation(t *testing.T) {
|
||||
store := memory.New("/tmp/test.jsonl")
|
||||
server := NewServer("/tmp/test.sock", store, "/tmp", "/tmp/test.db")
|
||||
|
||||
Reference in New Issue
Block a user