Documentation
¶
Overview ¶
Package desktoptest holds what the desktop app's tests share: a loop that stands in for the UI thread, with a clock that moves only when a test advances it, and a real notesd with a vault (internal/rpctest).
Index ¶
- Variables
- type Loop
- func (l *Loop) Advance(d time.Duration)
- func (l *Loop) After(d time.Duration, f func()) func()
- func (l *Loop) Drain()
- func (l *Loop) Now() time.Time
- func (l *Loop) Post(f func())
- func (l *Loop) Until(t testing.TB, what string, cond func() bool)
- func (l *Loop) UntilWithin(t testing.TB, what string, limit time.Duration, cond func() bool)
- type Notesd
Constants ¶
This section is empty.
Variables ¶
var Epoch = time.Date(2026, 11, 10, 9, 0, 0, 0, time.UTC)
Epoch is the loop's time zero.
Functions ¶
This section is empty.
Types ¶
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop stands in for the UI thread: workers Post to it from any goroutine, and the test runs what they posted on its own goroutine. Its clock moves only when the test calls Advance.
func (*Loop) Drain ¶
func (l *Loop) Drain()
Drain runs what has been posted so far, without waiting for more.
func (*Loop) Post ¶
func (l *Loop) Post(f func())
Post runs f on the test's goroutine, at its next Until or Drain.
func (*Loop) Until ¶
Until runs what workers post until cond holds, for at most 10 s.
Like the UI thread, which runs everything posted and then draws one frame, it runs every function waiting in the queue before it checks cond again. A cond that draws a frame thus draws one for each batch, not one for each function: when frames are slow (the race detector, a busy runner), more work waits, and one frame covers it all. A frame for each function made the wait grow with the frames' cost times the number of answers, past the limit on a slow runner.
type Notesd ¶
type Notesd struct {
T testing.TB
Srv *rpctest.Server
App *api.Client
Other *api.Client
Vault int64
Dir string
// Blobs is notesd's blob store, which the app reads by hash.
Blobs string
// Data is notesd's data directory, which Restart keeps.
Data string
// Down, while true, makes AppNotes return nil, as a lost connection.
Down bool
// contains filtered or unexported fields
}
Notesd is a real notesd with one vault, and two connections: the app's and another writer's.
func StartNotesd ¶
StartNotesd starts a notesd with an empty vault.
func StartNotesdWith ¶
StartNotesdWith is StartNotesd with the server's options, such as a fake domain (Options.Services). Its data directory is always a fresh one.
func (*Notesd) AppNotes ¶
func (n *Notesd) AppNotes() *api.NoteClient
AppNotes is the app's note domain, nil while Down.