const sharedData … // newWorkdir sets up a temporary Workdir with the given txtar-encoded content. // It also configures an eventBuffer to receive file event notifications. These // notifications are sent synchronously for each operation, such that once a // workdir file operation has returned the caller can expect that any relevant // file notifications are present in the buffer. // // It is the caller's responsibility to call the returned cleanup function. func newWorkdir(t *testing.T, txt string) (*Workdir, *eventBuffer, func()) { … } type eventBuffer … // onEvents collects adds events to the buffer; to be used with Workdir.AddWatcher. func (c *eventBuffer) onEvents(_ context.Context, events []protocol.FileEvent) { … } // take empties the buffer, returning its previous contents. func (c *eventBuffer) take() []protocol.FileEvent { … } func TestWorkdir_ReadFile(t *testing.T) { … } func TestWorkdir_WriteFile(t *testing.T) { … } // Test for file notifications following file operations. func TestWorkdir_FileWatching(t *testing.T) { … } func TestWorkdir_CheckForFileChanges(t *testing.T) { … } func TestSplitModuleVersionPath(t *testing.T) { … }