knowledgetest

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package knowledgetest makes knowledge packs for other packages' tests, through the format's own apply step, the way every pack a person attaches is made.

Index

Constants

This section is empty.

Variables

View Source
var DefaultFiles = map[string]string{
	"wiki/topics/buckets.md": "---\ntitle: Buckets\ntype: topic\nsummary: Naming\nsources: [doc:guide.txt]\nupdated: 2026-09-25\n---\n\nA bucket name is globally unique [src: doc:guide.txt].\n",
	"sources/guide.txt":      "the guide\n",
}

DefaultFiles is a pack of one page citing one source.

Functions

func Make

func Make(t testing.TB, name string, files map[string]string) *knowledge.Pack

Make applies files (DefaultFiles when nil) as one ingest into a new pack named name under a temporary directory, and returns it loaded.

func MakeCapped

func MakeCapped(t testing.TB, name string, files map[string]string, maxBytes int64) *knowledge.Pack

MakeCapped is Make for a pack held to maxBytes (a pack kept on this computer may hold more than Agentry keeps); zero is Agentry's cap.

Types

type Registry

type Registry struct {
	*httptest.Server

	// Scanning leaves an uploaded pack scanning, as the core does until
	// its job ends.
	Scanning bool
	// Forbid answers 403 for every knowledge route, as the core answers a
	// token minted before the knowledge scopes existed.
	Forbid bool
	// Requests is every request's method and path, in order.
	Requests []string
	// contains filtered or unexported fields
}

Registry is an in-process fake of a core registry's knowledge routes (docs/knowledge.md in the core), for the store's and the clients' tests: wrap and unwrap for the account a bearer token names and no other, create, upload (opened and checked as the core checks it), list, download and delete, answered in the core's JSON and problem shapes.

It also serves the Writing Voice's routes (voice.go): one voice per account, put for review and decided by Review or SetReviewOnRead.

It also serves an organization's shared packs (the core's /orgs/{org}/knowledge/): list, read, download, unwrap and export, for the organization's members alone (404 to anyone else, as the core answers), a member's export of a pack not marked exportable 403 knowledge-not-exportable. Shared packs are seeded with SeedShared; the organization's key is the fake's own, bound to the organization.

func NewRegistry

func NewRegistry(t testing.TB) *Registry

NewRegistry starts the fake; it closes with the test.

func (*Registry) EscapeLive

func (r *Registry) EscapeLive(owner string)

EscapeLive gives owner's live voice a terminal escape sequence, with a digest that matches it, as a registry that reviewed text it should not have would send.

func (*Registry) Finish

func (r *Registry) Finish()

Finish ends every scan, as the core's job does.

func (*Registry) Join

func (r *Registry) Join(org, owner, role string)

Join makes owner an active member of org, as role ("admin" or "member").

func (*Registry) Packs

func (r *Registry) Packs(owner string) int

Packs is how many packs owner keeps.

func (*Registry) Remove

func (r *Registry) Remove(org, owner string)

Remove ends owner's membership of org: every later call of theirs to the organization's routes is a 404, as the core answers.

func (*Registry) ReplaceShared

func (r *Registry) ReplaceShared(org, id string, files map[string]string)

ReplaceShared gives org's pack id new content, as an administrator's update does: the pack keeps its id and the tree and digest change.

func (*Registry) Review

func (r *Registry) Review(owner string, verdict VoiceVerdict)

Review decides owner's pending version: VoicePass makes it live (the live one previous; always-attach on the first time), VoiceFlag keeps it pending with a finding on the override question.

func (*Registry) SeedShared

func (r *Registry) SeedShared(t testing.TB, org, name string, files map[string]string) string

SeedShared makes a ready shared pack of org named name holding files (paths under wiki/ and sources/), sealed under a fresh data key wrapped for the organization, and answers its registry id.

func (*Registry) SetExportable

func (r *Registry) SetExportable(org, id string, on bool)

SetExportable marks org's pack id exportable by its members, or not.

func (*Registry) SetReviewOnRead

func (r *Registry) SetReviewOnRead(verdict VoiceVerdict)

SetReviewOnRead decides a pending version in review at the next GET /voice, as the core's job would have meanwhile; "" turns it off.

func (*Registry) TamperLive

func (r *Registry) TamperLive(owner string)

TamperLive changes owner's live text without its digest, as a registry that sends what it does not mean would.

func (*Registry) Token

func (r *Registry) Token(owner string) string

Token is a bearer token for owner, made the first time it is asked for.

type VoiceVerdict

type VoiceVerdict string

VoiceVerdict is how the fake decides a version in review.

const (
	VoicePass VoiceVerdict = "pass"
	VoiceFlag VoiceVerdict = "flag"
)

The fake's verdicts: pass makes the version live, flag keeps it pending with a finding on the override question.

Jump to

Keyboard shortcuts

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