syncthingtest

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package syncthingtest is an httptest stand-in for Syncthing's REST API: the endpoints the two adapters call, keyed by X-API-Key, keeping what they post. It is a test helper and nothing ships it.

Index

Constants

View Source
const ID = "SELFSEL-FSELFSE-LFSELFS-ELFSELF-SELFSEL-FSELFSE-LFSELFS-ELFSELF"

ID is the device id the fake answers as myID.

View Source
const Key = "fixture-api-key-7f3a"

Key is the API key the fixtures write into config.xml. Every test that runs a verb asserts it never reaches stdout or stderr.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fake

type Fake struct {
	T *testing.T

	Mu          sync.Mutex
	Devices     []syncthing.DeviceConfig
	DevicePosts int
	Folders     []syncthing.FolderConfig
	// FolderPosts counts POST /rest/config/folders.
	FolderPosts int
	// Pauses counts the PATCHes that paused a folder.
	Pauses int
	// Deletes is the folder ids DELETEd, in order.
	Deletes []string
	// FailDelete makes a folder DELETE answer 500.
	FailDelete bool
	// Extra is the folders "another project" holds: listed, never posted.
	Extra     []syncthing.ConfiguredFolder
	Connected map[string]bool
	// Listen is options.listenAddresses; ListenSets counts its PATCHes.
	Listen     []string
	ListenSets int
	Shutdowns  int
	FailStop   bool
	OnShutdown func()
	BadKey     int
}

A Fake is the server's state. A test reads and writes it under Mu.

func New

func New(t *testing.T) (*Fake, *httptest.Server)

New starts the fake and closes it with the test.

func (*Fake) DeviceIDs

func (f *Fake) DeviceIDs() []string

DeviceIDs answers the configured device ids, the instance's own first.

func (*Fake) FolderDevices

func (f *Fake) FolderDevices(id string) []string

FolderDevices answers the device ids of one configured folder, or nil when it is not configured.

Jump to

Keyboard shortcuts

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