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 ¶
- Variables
- func Make(t testing.TB, name string, files map[string]string) *knowledge.Pack
- func MakeCapped(t testing.TB, name string, files map[string]string, maxBytes int64) *knowledge.Pack
- type Registry
- func (r *Registry) EscapeLive(owner string)
- func (r *Registry) Finish()
- func (r *Registry) Join(org, owner, role string)
- func (r *Registry) Packs(owner string) int
- func (r *Registry) Remove(org, owner string)
- func (r *Registry) ReplaceShared(org, id string, files map[string]string)
- func (r *Registry) Review(owner string, verdict VoiceVerdict)
- func (r *Registry) SeedShared(t testing.TB, org, name string, files map[string]string) string
- func (r *Registry) SetExportable(org, id string, on bool)
- func (r *Registry) SetReviewOnRead(verdict VoiceVerdict)
- func (r *Registry) TamperLive(owner string)
- func (r *Registry) Token(owner string) string
- type VoiceVerdict
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
NewRegistry starts the fake; it closes with the test.
func (*Registry) EscapeLive ¶
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) Remove ¶
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 ¶
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 ¶
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 ¶
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 ¶
TamperLive changes owner's live text without its digest, as a registry that sends what it does not mean would.
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.