fwtest

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package fwtest provides test helpers for filewatcher v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeDirWatcher

type FakeDirWatcher[T any] struct {
	// contains filtered or unexported fields
}

FakeDirWatcher is an implementation of FileWatcher for testing with watching directories.

func NewFakeDirWatcher

func NewFakeDirWatcher[T any](dir fs.FS, parser filewatcher.DirParser[T]) (*FakeDirWatcher[T], error)

NewFakeDirWatcher creates a FakeDirWatcher with the initial data and the given DirParser.

It provides Update function to update the data after it's been created.

func (*FakeDirWatcher[T]) Close

func (dw *FakeDirWatcher[T]) Close() error

Close is a no-op.

func (*FakeDirWatcher[T]) Get

func (dw *FakeDirWatcher[T]) Get() T

Get implements FileWatcher by returning the last updated data.

func (*FakeDirWatcher[T]) Update

func (dw *FakeDirWatcher[T]) Update(dir fs.FS) error

Update updates the data stored in this FakeDirWatcher.

type FakeFileWatcher

type FakeFileWatcher[T any] struct {
	// contains filtered or unexported fields
}

FakeFileWatcher is an implementation of FileWatcher that does not actually read from a file, it simply returns the data given to it when it was initialized with NewFakeFilewatcher. It provides an additional Update method that allows you to update this data after it has been created.

func NewFakeFilewatcher

func NewFakeFilewatcher[T any](r io.Reader, parser filewatcher.Parser[T]) (*FakeFileWatcher[T], error)

NewFakeFilewatcher returns a pointer to a new FakeFileWatcher object initialized with the given io.Reader and Parser.

func (*FakeFileWatcher[T]) Close

func (fw *FakeFileWatcher[T]) Close() error

Close is a no-op.

func (*FakeFileWatcher[T]) Get

func (fw *FakeFileWatcher[T]) Get() T

Get returns the parsed data.

func (*FakeFileWatcher[T]) Update

func (fw *FakeFileWatcher[T]) Update(r io.Reader) error

Update updates the data of the FakeFileWatcher using the given io.Reader and the Parser used to initialize the FileWatcher.

This method is not threadsafe.

Jump to

Keyboard shortcuts

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