mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
* refactor: rename inspect to replay across the codebase Renames inspect-ui/ to replay-ui/, internal/inspect/ to internal/replay/, the CLI subcommand from `sanderling inspect` to `sanderling replay`, and updates all references in docs, Makefile, README, and Go comments. * feat(replay-ui): show spec filename with full path on hover RunList and RunDetail now render the basename of spec_path (e.g. login.spec.ts) with the full path available as a title tooltip.
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package replay
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestWatcher_UnsubscribeRemovesChannel(t *testing.T) {
|
|
w := NewWatcher(t.TempDir())
|
|
first := w.Subscribe()
|
|
second := w.Subscribe()
|
|
third := w.Subscribe()
|
|
|
|
if count := len(w.subscribers); count != 3 {
|
|
t.Fatalf("expected 3 subscribers, got %d", count)
|
|
}
|
|
|
|
w.Unsubscribe(second)
|
|
|
|
if count := len(w.subscribers); count != 2 {
|
|
t.Fatalf("expected 2 subscribers after Unsubscribe, got %d", count)
|
|
}
|
|
|
|
// broadcast should still notify remaining subscribers
|
|
w.broadcast()
|
|
select {
|
|
case <-first:
|
|
default:
|
|
t.Error("first subscriber did not receive broadcast")
|
|
}
|
|
select {
|
|
case <-third:
|
|
default:
|
|
t.Error("third subscriber did not receive broadcast")
|
|
}
|
|
}
|
|
|
|
func TestWatcher_UnsubscribeUnknownChannelIsNoop(t *testing.T) {
|
|
w := NewWatcher(t.TempDir())
|
|
existing := w.Subscribe()
|
|
|
|
stranger := make(chan struct{})
|
|
w.Unsubscribe(stranger)
|
|
|
|
if count := len(w.subscribers); count != 1 {
|
|
t.Fatalf("expected 1 subscriber after no-op Unsubscribe, got %d", count)
|
|
}
|
|
|
|
w.broadcast()
|
|
select {
|
|
case <-existing:
|
|
default:
|
|
t.Error("existing subscriber did not receive broadcast")
|
|
}
|
|
}
|