testing

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string
	User   *string
	Params map[string][]string
	Input  any
}

Call contains information about a method call.

type FakeClock

type FakeClock struct {
	Time time.Time
}

FakeClock is an k3.Clock that returns a user-provided time.

func (*FakeClock) Now

func (f *FakeClock) Now() time.Time

type FakeServer

type FakeServer struct {
	// Calls contains information about all the methods that were called in the fake server.
	Calls []Call
	// Posts contains all the posts that were published to the server.
	Posts []Post
	// contains filtered or unexported fields
}

FakeServer is a fake Bluesky server for testing.

func NewFakeServer

func NewFakeServer(options ...FakeServerOption) *FakeServer

NewFakeServer returns a fake Bluesky server for testing.

func (*FakeServer) AddUser

func (f *FakeServer) AddUser(identifier string, password string) *FakeServer

AddUser adds a user that can be authenticated to the server.

func (*FakeServer) AddUserDid

func (f *FakeServer) AddUserDid(userDid *identity.DIDDocument) *FakeServer

AddUserDid adds information about another user on the server.

func (*FakeServer) Close

func (f *FakeServer) Close()

Close shuts down the server.

func (*FakeServer) Register

func (f *FakeServer) Register(method *FakeServerMethod) *FakeServer

Register adds a method to the server.

func (*FakeServer) ServeHTTP

func (f *FakeServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*FakeServer) URL

func (f *FakeServer) URL() string

URL returns the server's URL.

type FakeServerMethod

type FakeServerMethod struct {
	// contains filtered or unexported fields
}

FakeServerMethod contains a method that can be registered using Register.

Use NewCommand and NewFunction to create FakeServerMethods.

func NewCommand

func NewCommand[O any](reqType xrpc.XRPCRequestType, name string, def ProcedureDefinition[O]) *FakeServerMethod

NewCommand is used to define a method that doesn't take an input object.

func NewFunction

func NewFunction[I any, O any](reqType xrpc.XRPCRequestType, name string, def FunctionDefinition[I, O]) *FakeServerMethod

NewFunction is used to define a method that takes an input object.

type FakeServerOption

type FakeServerOption func(*FakeServer)

func WithClock

func WithClock(clock k3.Clock) FakeServerOption

WithClock makes the FakeServer use the given clock.

type FunctionDefinition

type FunctionDefinition[I any, O any] func(user *string, params map[string][]string, input *I) (*O, error)

type Post

type Post struct {
	Repo   string
	Rkey   string
	Record *bsky.FeedPost
}

Post contains information about a published Bluesky post.

type ProcedureDefinition

type ProcedureDefinition[O any] func(user *string, params map[string][]string) (*O, error)

Jump to

Keyboard shortcuts

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