agentcommon

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package agentcommon provides a production-router fixture for Agent Packages and Agent Plugins server-route suites.

Role

Test support, outside the modules, for test/server/artifacts/agentpackages and test/server/artifacts/agentplugins.

Inputs

  • The production router from test/server/support/harness (app.NewRouter), an in-memory store and a file-system blob store, and the seeding of test/server/support.

Outputs

  • World, from NewWorld: the router with the users deployer and user and the local repository libs-local.
  • Assertions the two suites share: WantStatus, HitsOf and SetTrashcan.

References

Status

Implemented P9b (issue 673).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HitsOf

func HitsOf(t *testing.T, rec *httptest.ResponseRecorder) []map[string]any

HitsOf returns the results array of a search response. It fails t unless rec is 200 OK with a JSON body that has a results array.

func SetTrashcan

func SetTrashcan(t *testing.T, db *inmem.Store, on bool)

SetTrashcan turns the trash can on or off in db, with a 14-day retention, and fails t when the setting cannot be stored.

func WantStatus

func WantStatus(t *testing.T, rec *httptest.ResponseRecorder, want int)

WantStatus fails t, printing the response body, unless rec has the status want.

Types

type World

type World struct {
	T       *testing.T
	Handler http.Handler
	DB      *inmem.Store
	Blobs   blob.Store
}

World is the production router over an in-memory store and a file-system blob store, built by NewWorld for one test. Do sends requests to Handler; DB and Blobs let a test seed state or check what a request left behind.

func NewWorld

func NewWorld(t *testing.T) *World

NewWorld builds a World for t: a seeded store with the users deployer and user, both with the password "pw", and the generic local repository libs-local; blobs under t's temporary directory; and the router with Basic authentication. It fails t when any of them cannot be built.

func (*World) Do

func (w *World) Do(method, path, as, body string, headers ...string) *httptest.ResponseRecorder

Do sends a request to the world's router as the user as, with the password "pw" over Basic, or without credentials when as is empty. headers are name and value pairs; a trailing name without a value is ignored.

Jump to

Keyboard shortcuts

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