plugintest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package plugintest provides a made-up source plugin for tests: hosts can run against it, and the SDK's own tests and the example plugin use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Image

func Image(ref string) []byte

Image returns the PNG the fake serves for ref: a small image in a colour derived from ref.

Types

type Chapter

type Chapter struct {
	Chapter *sourcev1.Chapter
	Pages   int
}

Chapter is a fake chapter with a number of pages.

type Fake

type Fake struct {
	plugin.Unimplemented

	// ID of the plugin, "fake" by default.
	ID string
	// Sources it serves.
	Sources []*Source
	// PageSize is the number of series per Popular/Latest/Search page, 2 by
	// default.
	PageSize int
	// Config, when set, is the plugin-level configuration: GetInfo declares
	// its schema and GetConfig/SetConfig use it.
	Config *plugin.PluginConfig
	// Packages, when set, makes the fake a plugin with the PACKAGES capability:
	// a source belongs to the package that lists it, and is listed only while
	// that package is installed and its language is enabled.
	Packages []*Package
	// Langs are the languages the plugin offers sources in; empty means all.
	Langs []string
	// Jobs, when set, makes the fake a plugin with the JOBS capability. [New]
	// sets up "refresh" and "hold".
	Jobs *jobs.Runner
	// contains filtered or unexported fields
}

Fake is an in-memory source plugin. Build one with New or fill in Sources yourself. It is safe for concurrent use once serving.

func New

func New() *Fake

New returns a fake with two sources: "Example Comics" (en: latest, search, filters, URL resolving, settings) and "Beispiel Comics" (de: search only), each with a few series, chapters and pages. Everything is made up.

func (*Fake) BreakOrigin

func (f *Fake) BreakOrigin(id string, broken bool)

BreakOrigin makes refreshing an origin fail with STORE_FETCH_FAILED, or work again.

func (*Fake) Calls

func (f *Fake) Calls() map[string]int

Calls returns how often each method was called.

func (*Fake) DisableJob

func (f *Fake) DisableJob(id, reason string)

DisableJob gives a job a disabled reason, so it refuses to run with JOB_DISABLED; "" enables it again.

func (*Fake) FetchImage

func (*Fake) GetConfig

func (*Fake) GetJob

func (*Fake) GetJobRun

func (*Fake) GetNetworkProfile

GetNetworkProfile returns the pushed profile, password left out, or none.

func (*Fake) InstallPackage

InstallPackage installs the offered version; the same version again is OK.

func (*Fake) Latest

func (*Fake) ListJobs

ListJobs lists the fake's jobs, when it has them.

func (*Fake) ListOrigins

ListOrigins lists the origins the packages' offers name.

func (*Fake) Popular

func (*Fake) Profile

func (f *Fake) Profile(sourceID string) *sourcev1.NetworkProfile

Profile returns the network profile pushed for a source, if any.

func (*Fake) RefreshOrigin

RefreshOrigin pretends to fetch an origin; see Fake.BreakOrigin.

func (*Fake) Release

func (f *Fake) Release()

Release ends the running "hold" job.

func (*Fake) ReloadPackage

ReloadPackage answers with the package as it is: there is nothing to load.

func (*Fake) RunJob

func (*Fake) Search

func (*Fake) SetConfig

func (*Fake) SetSourceHealthCheck

SetSourceHealthCheck turns a source's (pretend) scheduled checks on or off.

type Offer

type Offer struct{ OriginID, OriginName, Version string }

Offer is where a fake package can be installed from.

type Package

type Package struct {
	Package *sourcev1.Package
	Sources []*Source
	// contains filtered or unexported fields
}

Package is a fake package: what it offers, the sources it provides and whether it starts out installed.

func NewPackage

func NewPackage(id, name, version string, sources []*Source, offers ...Offer) *Package

NewPackage describes a package that provides sources, offered by origins. Its version is the newest offered.

func (*Package) Installed

func (p *Package) Installed(version string) *Package

Installed makes the package start out installed at version.

type Series

type Series struct {
	Series   *sourcev1.Series
	Chapters []*Chapter
}

Series is a fake series with its chapters.

type Source

type Source struct {
	Source *sourcev1.Source
	Series []*Series
}

Source is a fake source and its catalogue.

func NewSource

func NewSource(id, name, lang string, titles []string, caps ...sourcev1.SourceCapability) *Source

NewSource builds a source with one series per title, three chapters per series and four pages per chapter.

Jump to

Keyboard shortcuts

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