(t *testing.T)
| 3039 | } |
| 3040 | |
| 3041 | func TestManagerCreateTaskUsesTrustedActorContext(t *testing.T) { |
| 3042 | t.Parallel() |
| 3043 | |
| 3044 | store := newInMemoryManagerStore() |
| 3045 | manager := newTaskManagerForTest(t, store) |
| 3046 | actor, err := DeriveAgentSessionActorContext("sess-123") |
| 3047 | if err != nil { |
| 3048 | t.Fatalf("DeriveAgentSessionActorContext() error = %v", err) |
| 3049 | } |
| 3050 | |
| 3051 | created, err := manager.CreateTask(context.Background(), CreateTask{ |
| 3052 | Scope: ScopeGlobal, |
| 3053 | Title: "Investigate task manager", |
| 3054 | }, actor) |
| 3055 | if err != nil { |
| 3056 | t.Fatalf("CreateTask() error = %v", err) |
| 3057 | } |
| 3058 | |
| 3059 | if got, want := created.CreatedBy, actor.Actor; got != want { |
| 3060 | t.Fatalf("created.CreatedBy = %#v, want %#v", got, want) |
| 3061 | } |
| 3062 | if got, want := created.Origin, actor.Origin; got != want { |
| 3063 | t.Fatalf("created.Origin = %#v, want %#v", got, want) |
| 3064 | } |
| 3065 | if created.Owner != nil { |
| 3066 | t.Fatalf("created.Owner = %#v, want nil", created.Owner) |
| 3067 | } |
| 3068 | if got, want := created.Status, TaskStatusReady; got != want { |
| 3069 | t.Fatalf("created.Status = %q, want %q", got, want) |
| 3070 | } |
| 3071 | if got, want := created.Priority, DefaultPriority; got != want { |
| 3072 | t.Fatalf("created.Priority = %q, want %q", got, want) |
| 3073 | } |
| 3074 | if got, want := created.MaxAttempts, DefaultTaskMaxAttempts; got != want { |
| 3075 | t.Fatalf("created.MaxAttempts = %d, want %d", got, want) |
| 3076 | } |
| 3077 | if got, want := created.ApprovalPolicy, ApprovalPolicyNone; got != want { |
| 3078 | t.Fatalf("created.ApprovalPolicy = %q, want %q", got, want) |
| 3079 | } |
| 3080 | if got, want := created.ApprovalState, ApprovalStateNotRequired; got != want { |
| 3081 | t.Fatalf("created.ApprovalState = %q, want %q", got, want) |
| 3082 | } |
| 3083 | |
| 3084 | events, err := store.ListTaskEvents(context.Background(), EventQuery{TaskID: created.ID}) |
| 3085 | if err != nil { |
| 3086 | t.Fatalf("ListTaskEvents() error = %v", err) |
| 3087 | } |
| 3088 | if len(events) != 1 { |
| 3089 | t.Fatalf("len(events) = %d, want 1", len(events)) |
| 3090 | } |
| 3091 | if got, want := events[0].EventType, taskEventCreated; got != want { |
| 3092 | t.Fatalf("events[0].EventType = %q, want %q", got, want) |
| 3093 | } |
| 3094 | if got, want := events[0].Actor, actor.Actor; got != want { |
| 3095 | t.Fatalf("events[0].Actor = %#v, want %#v", got, want) |
| 3096 | } |
| 3097 | if got, want := events[0].Origin, actor.Origin; got != want { |
| 3098 | t.Fatalf("events[0].Origin = %#v, want %#v", got, want) |
nothing calls this directly
no test coverage detected