Skip to content

Commit b7d8dd5

Browse files
author
sg-architect
committed
fix(taskstore): address review — errors.Is, Bob own task, var naming
- Use errors.Is instead of direct comparison for ErrTaskNotFound - Have Bob create his own task so List loop actually executes - Verify Bob's List returns his task while filtering Alice's - Rename loop variable for clarity
1 parent 667f982 commit b7d8dd5

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

a2asrv/taskstore/store_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,19 +538,35 @@ func TestInMemoryTaskStore_CrossTenantIsolation(t *testing.T) {
538538
// Bob attempts to read Alice's task — must return ErrTaskNotFound.
539539
bobCtx := context.WithValue(ctx, userKey, "bob")
540540
_, err = store.Get(bobCtx, task.ID)
541-
if err == nil || err != a2a.ErrTaskNotFound {
541+
if !errors.Is(err, a2a.ErrTaskNotFound) {
542542
t.Fatalf("bob Get: want ErrTaskNotFound, got %v", err)
543543
}
544544

545-
// Bob's ListTasks excludes Alice's task.
545+
// Bob creates his own task, then verifies List returns his task
546+
// while correctly excluding Alice's.
547+
bobTask := &a2a.Task{
548+
ID: a2a.NewTaskID(),
549+
Status: a2a.TaskStatus{State: a2a.TaskStateSubmitted},
550+
}
551+
if _, err := store.Create(bobCtx, bobTask); err != nil {
552+
t.Fatalf("bob Create failed: %v", err)
553+
}
554+
546555
resp, err := store.List(bobCtx, &a2a.ListTasksRequest{})
547556
if err != nil {
548557
t.Fatalf("bob List failed: %v", err)
549558
}
550-
for _, tsk := range resp.Tasks {
551-
if tsk.ID == task.ID {
559+
foundBob := false
560+
for _, t := range resp.Tasks {
561+
if t.ID == task.ID {
552562
t.Fatal("bob List should not include alice's task")
553563
}
564+
if t.ID == bobTask.ID {
565+
foundBob = true
566+
}
567+
}
568+
if !foundBob {
569+
t.Fatal("bob List should include bob's own task")
554570
}
555571

556572
// Alice can still Get her own task.

0 commit comments

Comments
 (0)