| 81 | } |
| 82 | |
| 83 | func TestPathStore_Subscribe_MultipleSubscribers(t *testing.T) { |
| 84 | t.Parallel() |
| 85 | |
| 86 | ps := agentgit.NewPathStore() |
| 87 | chatID := uuid.New() |
| 88 | |
| 89 | ch1, unsub1 := ps.Subscribe(chatID) |
| 90 | defer unsub1() |
| 91 | ch2, unsub2 := ps.Subscribe(chatID) |
| 92 | defer unsub2() |
| 93 | |
| 94 | ps.AddPaths([]uuid.UUID{chatID}, []string{"/file"}) |
| 95 | |
| 96 | ctx := testutil.Context(t, testutil.WaitShort) |
| 97 | for i, ch := range []<-chan struct{}{ch1, ch2} { |
| 98 | select { |
| 99 | case <-ch: |
| 100 | // OK |
| 101 | case <-ctx.Done(): |
| 102 | t.Fatalf("subscriber %d did not receive notification", i) |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func TestPathStore_Unsubscribe_StopsNotifications(t *testing.T) { |
| 108 | t.Parallel() |