MCPcopy Create free account
hub / github.com/compozy/agh / TestManagerCreateTaskRecordsIntentWithoutRuns

Function TestManagerCreateTaskRecordsIntentWithoutRuns

internal/task/manager_test.go:3102–3166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3100}
3101
3102func TestManagerCreateTaskRecordsIntentWithoutRuns(t *testing.T) {
3103 t.Parallel()
3104
3105 tests := []struct {
3106 name string
3107 actor func(t *testing.T) ActorContext
3108 spec CreateTask
3109 }{
3110 {
3111 name: "user-created ready task",
3112 actor: func(t *testing.T) ActorContext {
3113 t.Helper()
3114 return validActorContext()
3115 },
3116 spec: CreateTask{
3117 Scope: ScopeGlobal,
3118 Title: "User intent only",
3119 },
3120 },
3121 {
3122 name: "agent-created approval task",
3123 actor: func(t *testing.T) ActorContext {
3124 t.Helper()
3125 actor, err := DeriveAgentSessionActorContext("sess-agent-create")
3126 if err != nil {
3127 t.Fatalf("DeriveAgentSessionActorContext() error = %v", err)
3128 }
3129 return actor
3130 },
3131 spec: CreateTask{
3132 Scope: ScopeGlobal,
3133 Title: "Agent intent only",
3134 ApprovalPolicy: ApprovalPolicyManual,
3135 },
3136 },
3137 }
3138
3139 for _, tc := range tests {
3140 t.Run(tc.name, func(t *testing.T) {
3141 t.Parallel()
3142
3143 store := newInMemoryManagerStore()
3144 manager := newTaskManagerForTest(t, store)
3145 actor := tc.actor(t)
3146
3147 created, err := manager.CreateTask(context.Background(), tc.spec, actor)
3148 if err != nil {
3149 t.Fatalf("CreateTask() error = %v", err)
3150 }
3151 runs, err := store.ListTaskRuns(context.Background(), RunQuery{TaskID: created.ID})
3152 if err != nil {
3153 t.Fatalf("ListTaskRuns() error = %v", err)
3154 }
3155 if len(runs) != 0 {
3156 t.Fatalf("len(runs) = %d, want 0", len(runs))
3157 }
3158 if got, want := created.CreatedBy, actor.Actor; got != want {
3159 t.Fatalf("created.CreatedBy = %#v, want %#v", got, want)

Callers

nothing calls this directly

Calls 7

validActorContextFunction · 0.85
newInMemoryManagerStoreFunction · 0.85
newTaskManagerForTestFunction · 0.85
RunMethod · 0.65
CreateTaskMethod · 0.65
ListTaskRunsMethod · 0.65

Tested by

no test coverage detected