Documentation
¶
Overview ¶
Package wikifake is a wikiwikibangbang that lives in a test: the routes Atlas's adapter reads, answering from pages a test writes, under an https test server.
It implements the source's contract as its ADR-0120 and its item API state it — an unreadable item is a 404, a restriction and a hold are omitted when there is none, a protected passage is a secret mark over the placeholder for a reader who may not read it, the change feed names an item the caller cannot read as "" — so the tests that use it test Atlas against the contract rather than against whatever the fake happened to answer.
Index ¶
- Constants
- type Attachment
- type Block
- type Grant
- type Mark
- type Page
- type Server
- func (s *Server) Attach(pageID string, a Attachment)
- func (s *Server) Close()
- func (s *Server) Edit(id string, fn func(*Page))
- func (s *Server) Host() string
- func (s *Server) Put(p Page)
- func (s *Server) Set(fn func(*Server))
- func (s *Server) Touch(id string)
- func (s *Server) TouchAccount()
- func (s *Server) URL() string
- func (s *Server) Watched() []string
Constants ¶
const Placeholder = "▒▒▒▒▒▒▒▒"
Placeholder is what a reader who may not read a passage reads.
const Token = "wiki-read-token-0123456789"
Token is the read token the fake accepts.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
Attachment is one file of a page.
type Block ¶
type Block struct {
Kind string `json:"kind"`
Text string `json:"text,omitempty"`
Marks []Mark `json:"marks,omitempty"`
// Ref names an image's attachment or an embed's item; Level a heading's
// level and Tone a panel's tone.
Ref string `json:"ref,omitempty"`
Level int `json:"level,omitempty"`
Tone string `json:"tone,omitempty"`
}
Block is one block of a body.
type Mark ¶
type Mark struct {
Type string `json:"type"`
Start int `json:"start"`
End int `json:"end"`
Href string `json:"href,omitempty"`
Ref string `json:"ref,omitempty"`
}
Mark is one mark over a block's text, in runes.
type Page ¶
type Page struct {
ID string
Key string
Space string
Parent string
Title string
State string
Presence string
Version int
Labels []string
Properties map[string]any
Body []Block
// ReadRestriction and EditRestriction name who may read or edit.
ReadRestriction []string
EditRestriction []string
Held bool
// Unreadable makes the page a 404 for the account, as a restriction that
// does not name it would.
Unreadable bool
// OmitPresence leaves presence out of the answer, as a source that does
// not report it would.
OmitPresence bool
}
Page is one item of the fake.
type Server ¶
type Server struct {
TS *httptest.Server
// The account's standing.
Scope string
Admin bool
Erasure bool
System []string
Spaces []Grant
RolesMissing bool
// Down makes every request answer 503, as a source in an outage.
Down bool
// Redirect sends every request to another address.
Redirect string
// Seen records every request, "METHOD path".
Seen []string
// Tokens records every bearer token presented.
Tokens []string
// contains filtered or unexported fields
}
Server is the fake.
func (*Server) Attach ¶
func (s *Server) Attach(pageID string, a Attachment)
Attach adds a file to a page.
func (*Server) Edit ¶
Edit changes a page in place, bumps its version and reports the change in the feed of whoever watches it.
func (*Server) Touch ¶
Touch writes a feed entry for a page if it is watched: its id when the account may read it, "" when it may not.
func (*Server) TouchAccount ¶
func (s *Server) TouchAccount()
TouchAccount writes the entry the source always lists: a change to the account's own roles, which names no item.