testplugin

command
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Command testplugin is a plugin that exercises every part of the contract and does nothing useful.

That is the point. A host needs something honest to test against: something that answers when it should, reports what it spent, is handed a credential and proves it received one without printing it, and — on request — crashes, hangs past its deadline, or writes rubbish to standard error. A real plugin cannot be asked to do those things on demand, and a fake one built inside the host's own tests proves only that the host agrees with itself.

It is also the shortest complete example of writing a plugin, so it is worth reading before the first real one.

Making it misbehave

Behaviour comes from behaviour.json beside the binary, read fresh on every call so a test can change its mind mid-flight. A missing file is a plugin that behaves.

{
  "crash_at": "answer",   // "start", "settings", "notify" or "answer"
  "exit_code": 3,         // what it exits with when it crashes
  "hang": "10s",          // how long to ignore the deadline for
  "leak_secret": true,    // print the credential to standard error
  "leak_database": true,  // print its own connection string to standard error
  "stderr": "...",        // print this to standard error at startup
  "spend": 1200           // tokens to report having spent on each call
}

Jump to

Keyboard shortcuts

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