Documentation
¶
Overview ¶
Package fakesync is a fake sync adapter for tests of the harness side of the sync-adapter protocol (folder-sync plan §4.3, docs/sync-adapters.md): a POSIX shell script the test writes into its own temp directory and launches as `/bin/sh <script> <verb>` — an argv array, never `sh -c`, and the fresh file is READ by the shell rather than exec'd, which is what macOS's first-exec assessment and Linux's ETXTBSY need (the repository's rule for a script fixture).
The script appends one line per call to its record file — the verb, the BRIGADE_STATE_DIR it was given and its stdin request, tab-separated — and answers each verb with a canned 4.3 envelope from Answers. Nothing here ships.
Index ¶
Constants ¶
const ( SelfPeer = "SELF-DEVICE-1" DefaultDescribe = `{"name":"syncthing","version":"test","protocol_version":"sync/1"}` DefaultAttach = `{"peer":"` + SelfPeer + `"}` DefaultApply = `{"folders":[{"id":"f1","state":"idle"}],"peers":[{"peer":"P1","connected":true}]}` DefaultStatus = `{"running":true,"peer":"` + SelfPeer + `","folders":[],"peers":[]}` DefaultDetach = `{"stopped":true}` )
The defaults: a sync/1 adapter named syncthing whose engine's device id is SelfPeer, one idle folder and one connected peer.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Answers ¶
type Answers struct {
Describe string
Attach string
Apply string
Status string
Detach string
// ApplySequence, when set, is apply's result call by call: the first
// apply answers the first entry, the second the second, and every
// later one the last. It takes the place of Apply.
ApplySequence []string
// ErrorOn lists the verbs that fail.
ErrorOn []string
ErrorMessage string
}
Answers are the canned results, each the raw JSON of the verb's `result` member. A zero member takes the default below; ErrorOn names verbs answered with a failing envelope (code `unavailable`, exit 9, the message ErrorMessage) instead.
type Fake ¶
type Fake struct {
// Argv is the argv prefix a Client runs: /bin/sh and the script.
Argv []string
// RecordPath is the file every call is appended to.
RecordPath string
}
A Fake is one written script.