desktoptest

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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 NewLoop

func NewLoop() *Loop

NewLoop makes a loop.

func (*Loop) Advance

func (l *Loop) Advance(d time.Duration)

Advance moves the clock by d and runs the timers that come due, in order.

func (*Loop) After

func (l *Loop) After(d time.Duration, f func()) func()

After runs f on the test's goroutine once Advance moves the clock d on.

func (*Loop) Drain

func (l *Loop) Drain()

Drain runs what has been posted so far, without waiting for more.

func (*Loop) Now

func (l *Loop) Now() time.Time

Now is the loop's time.

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

func (l *Loop) Until(t testing.TB, what string, cond func() bool)

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.

func (*Loop) UntilWithin

func (l *Loop) UntilWithin(t testing.TB, what string, limit time.Duration, cond func() bool)

UntilWithin is Until with its own limit.

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

func StartNotesd(t testing.TB) *Notesd

StartNotesd starts a notesd with an empty vault.

func StartNotesdWith

func StartNotesdWith(t testing.TB, o rpctest.Options) *Notesd

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.

func (*Notesd) Create

func (n *Notesd) Create(path, content string) string

Create makes a note as another writer and returns its hash.

func (*Notesd) Read

func (n *Notesd) Read(path string) *api.Note

Read reads a note as another writer.

func (*Notesd) Restart

func (n *Notesd) Restart()

Restart stops notesd and starts it again on the same data, on a new socket; the connections are made again.

func (*Notesd) Write

func (n *Notesd) Write(path, base, content string) string

Write writes a note as another writer, from base, and returns its hash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL