Documentation
¶
Overview ¶
Package streamstest is a fake AudD stream API for tests: stream management methods, longpoll, and the recent-results endpoint.
Index ¶
- Constants
- func Category(radioID int) string
- func RecentBody(capacity int, songs ...map[string]any) json.RawMessage
- type Call
- type Server
- func (s *Server) CallbackURL() string
- func (s *Server) Calls() []Call
- func (s *Server) Client() *audd.Client
- func (s *Server) ClientWithToken(tok string) *audd.Client
- func (s *Server) Count(method string) int
- func (s *Server) FailNextPolls(n int)
- func (s *Server) FailNextRecent(n int)
- func (s *Server) HTTPClient() *http.Client
- func (s *Server) Push(radioID int, body json.RawMessage)
- func (s *Server) PushMatch(radioID int, timestamp, artist, title string, playLength int)
- func (s *Server) PushMatchFor(tok string, radioID int, timestamp, artist, title string, playLength int)
- func (s *Server) PushNotification(radioID, code int, message string, running bool, at int64)
- func (s *Server) SetNoCallbackURL()
- func (s *Server) SetRecent(radioID int, body json.RawMessage)
- func (s *Server) SetStreams(streams ...Stream)
- func (s *Server) SetToken(tok string)
- func (s *Server) Streams() []Stream
- type Stream
Constants ¶
const Token = "0123456789abcdef0123456789abcdef"
Token is the placeholder API token the fake accepts.
Variables ¶
This section is empty.
Functions ¶
func RecentBody ¶
func RecentBody(capacity int, songs ...map[string]any) json.RawMessage
RecentBody builds a getChannelById response holding songs as a ring buffer of the given capacity, the way AudD returns it: Elements[(oldest+i) % capacity] runs from the oldest to the newest, unused slots are null.
Types ¶
type Call ¶
type Call struct {
Method string // AudD method ("getStreams", "longpoll", "getChannelById", ...)
Params url.Values
}
Call is one request the fake received.
type Server ¶
Server is a fake api.audd.io.
func New ¶
New starts a fake server. Longpoll requests wait at most lpTimeout (instead of the requested timeout) before answering with a keepalive.
func (*Server) CallbackURL ¶
CallbackURL returns the account's callback URL.
func (*Server) ClientWithToken ¶
ClientWithToken is Client with another API token.
func (*Server) FailNextPolls ¶
FailNextPolls makes the next n longpoll requests return HTTP 500.
func (*Server) FailNextRecent ¶
FailNextRecent makes the next n recent-results requests return HTTP 500.
func (*Server) HTTPClient ¶
HTTPClient returns a client that sends every request (whatever its host) to the fake.
func (*Server) Push ¶
func (s *Server) Push(radioID int, body json.RawMessage)
Push queues a raw longpoll body for a stream.
func (*Server) PushMatchFor ¶
func (s *Server) PushMatchFor(tok string, radioID int, timestamp, artist, title string, playLength int)
PushMatchFor queues a recognition for a stream's longpoll category under another API token.
func (*Server) PushNotification ¶
PushNotification queues a stream notification for a stream's longpoll.
func (*Server) SetNoCallbackURL ¶
func (s *Server) SetNoCallbackURL()
SetNoCallbackURL makes getCallbackUrl answer with error 19.
func (*Server) SetRecent ¶
func (s *Server) SetRecent(radioID int, body json.RawMessage)
SetRecent sets the getChannelById response for a stream.
func (*Server) SetStreams ¶
SetStreams replaces the account's streams.