(t *testing.T)
| 3682 | } |
| 3683 | |
| 3684 | func TestManagerUpdateTaskTogglesAutoEnqueueOnReady(t *testing.T) { |
| 3685 | t.Parallel() |
| 3686 | |
| 3687 | store := newInMemoryManagerStore() |
| 3688 | manager := newTaskManagerForTest(t, store) |
| 3689 | actor := validActorContext() |
| 3690 | |
| 3691 | created, err := manager.CreateTask( |
| 3692 | context.Background(), |
| 3693 | CreateTask{Scope: ScopeGlobal, Title: "Toggle"}, |
| 3694 | actor, |
| 3695 | ) |
| 3696 | if err != nil { |
| 3697 | t.Fatalf("CreateTask() error = %v", err) |
| 3698 | } |
| 3699 | if created.AutoEnqueueOnReady { |
| 3700 | t.Fatal("created.AutoEnqueueOnReady = true, want false default") |
| 3701 | } |
| 3702 | |
| 3703 | // Ordered, state-sharing subtests: each step depends on the prior patch, so they |
| 3704 | // run serially (no t.Parallel) to prove that omitting the field preserves it. |
| 3705 | t.Run("Should enable the flag when patched to true", func(t *testing.T) { |
| 3706 | enable := true |
| 3707 | updated, err := manager.UpdateTask( |
| 3708 | context.Background(), |
| 3709 | created.ID, |
| 3710 | Patch{AutoEnqueueOnReady: &enable}, |
| 3711 | actor, |
| 3712 | ) |
| 3713 | if err != nil { |
| 3714 | t.Fatalf("UpdateTask(enable) error = %v", err) |
| 3715 | } |
| 3716 | if !updated.AutoEnqueueOnReady { |
| 3717 | t.Fatal("updated.AutoEnqueueOnReady = false, want true") |
| 3718 | } |
| 3719 | }) |
| 3720 | |
| 3721 | t.Run("Should preserve the flag when the patch omits it", func(t *testing.T) { |
| 3722 | title := "Renamed but auto-enqueue untouched" |
| 3723 | updated, err := manager.UpdateTask( |
| 3724 | context.Background(), |
| 3725 | created.ID, |
| 3726 | Patch{Title: &title}, |
| 3727 | actor, |
| 3728 | ) |
| 3729 | if err != nil { |
| 3730 | t.Fatalf("UpdateTask(omit) error = %v", err) |
| 3731 | } |
| 3732 | if !updated.AutoEnqueueOnReady { |
| 3733 | t.Fatal("updated.AutoEnqueueOnReady = false after omitted patch, want preserved true") |
| 3734 | } |
| 3735 | }) |
| 3736 | |
| 3737 | t.Run("Should disable the flag when patched to false", func(t *testing.T) { |
| 3738 | disable := false |
| 3739 | updated, err := manager.UpdateTask( |
| 3740 | context.Background(), |
| 3741 | created.ID, |
nothing calls this directly
no test coverage detected