Documentation
¶
Overview ¶
Package opencodetest is a FAKE opencode v2 server for muster's tests and browser suite: the routes muster-mirror reads (shaped from upstream's packages/protocol/openapi.json at 6ec5682), HTTP Basic auth with user "opencode", and pair tokens signed the way upstream signs them (packages/server/src/auth.ts), so a token it issues has the real shape and lifetime. Every request is recorded (Requests), which is how tests prove muster-mirror never calls anything else.
Everything it serves is synthetic: tests put sessions and messages in.
Index ¶
- Constants
- type Request
- type Server
- func (s *Server) Emit(sid, typ string, data map[string]any)
- func (s *Server) FailEvents(on bool)
- func (s *Server) Issue() string
- func (s *Server) IssueAt(exp time.Time) string
- func (s *Server) PutMessage(sid string, m map[string]any)
- func (s *Server) PutSession(id, title, parent string)
- func (s *Server) RefuseRedeem(on bool)
- func (s *Server) Requests() []Request
- func (s *Server) Rotate(password string)
- func (s *Server) Sessions() []string
- func (s *Server) SetNow(now func() time.Time)
- func (s *Server) SetStatus(sid, status string)
- func (s *Server) Subscribers() int
Constants ¶
const TokenTTL = 30 * 24 * time.Hour
TokenTTL is upstream's SESSION_TTL_SECONDS: 30 days.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
Method string
Path string
// Authorized: it carried a credential the server accepted.
Authorized bool
}
Request is one request the server received.
type Server ¶
Server is the fake.
func (*Server) Emit ¶
Emit sends an event of type typ for session sid (data gets sessionID) to every open event stream.
func (*Server) FailEvents ¶
FailEvents makes the event stream answer 503 (on) — a server whose stream is down while its REST reads work — and closes none already open.
func (*Server) PutMessage ¶
PutMessage adds message m (a synthetic Session.Message.Info) to session sid, or replaces the one with the same "id" in place — as a streaming assistant message is rewritten — and announces it on the event stream.
func (*Server) PutSession ¶
PutSession adds or replaces a session (by id): a synthetic Session.Info, {"id", "title", "parentID"?, "time": {"created", "updated"}}.
func (*Server) RefuseRedeem ¶
RefuseRedeem makes the code redemption fail (a 401), as an expired code does.
func (*Server) Rotate ¶
Rotate replaces the server password, which revokes every token it issued (upstream: "rotating the password revokes every session").
func (*Server) Subscribers ¶
Subscribers is how many event streams are open.