Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package mobileremote
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAttemptWakeDeliversOnlyAfterTheObservedVersion(t *testing.T) {
|
|
wake := NewAttemptWake()
|
|
version := wake.Version("attempt-1")
|
|
result := make(chan bool, 1)
|
|
go func() { result <- wake.Wait(context.Background(), "attempt-1", version) }()
|
|
|
|
wake.Notify("attempt-1")
|
|
select {
|
|
case notified := <-result:
|
|
if !notified {
|
|
t.Fatal("Wait returned false after a notification")
|
|
}
|
|
case <-time.After(time.Second):
|
|
t.Fatal("Wait did not receive the notification")
|
|
}
|
|
}
|
|
|
|
func TestAttemptWakeDoesNotBlockWhenNotificationPrecedesWait(t *testing.T) {
|
|
wake := NewAttemptWake()
|
|
wake.Notify("attempt-1")
|
|
if !wake.Wait(context.Background(), "attempt-1", 0) {
|
|
t.Fatal("Wait missed an already-recorded notification")
|
|
}
|
|
}
|
|
|
|
func TestAttemptWakeForgetRemovesRetainedVersion(t *testing.T) {
|
|
wake := NewAttemptWake()
|
|
wake.Notify("attempt-1")
|
|
wake.Forget("attempt-1")
|
|
if got := wake.Version("attempt-1"); got != 0 {
|
|
t.Fatalf("forgotten attempt version = %d, want 0", got)
|
|
}
|
|
}
|
|
|
|
func TestAttemptWakeCanBeCancelled(t *testing.T) {
|
|
wake := NewAttemptWake()
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
|
|
defer cancel()
|
|
if wake.Wait(ctx, "attempt-1", 0) {
|
|
t.Fatal("Wait returned true without a notification")
|
|
}
|
|
}
|