geminitest

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package geminitest provides a test server and functions to help write tests for gemini servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequest

func NewRequest(target string) *gemini.Request

NewRequest returns a Reqaust for use in tests.

Types

type ResponseRecorder

type ResponseRecorder struct {
	Body *bytes.Buffer
	Meta string
	Code gemini.StatusCode
}

ResponseRecorder may be used in test to capture the output of a Handler.

func NewResponseRecorder

func NewResponseRecorder() *ResponseRecorder

NewResponseRecorder returns a response recorder ready to use.

func (*ResponseRecorder) Failure

func (r *ResponseRecorder) Failure(ctx context.Context, code gemini.StatusCode, msg string)

Failure implements the Failure method of the ResponseWriter interface.

func (*ResponseRecorder) Input

func (r *ResponseRecorder) Input(ctx context.Context, prompt string, isSensitive bool)

Input implements the Input method of the ResponseWriter interface.

func (*ResponseRecorder) Redirect

func (r *ResponseRecorder) Redirect(ctx context.Context, redirectURL string, isPermanant bool)

Redirect implements the Redirect method of the ResponseWriter interface.

func (*ResponseRecorder) Success

func (r *ResponseRecorder) Success(ctx context.Context, mimeType string) io.Writer

Success implements the Success method of the ResponseWriter interface.

type Server

type Server struct {
	Listener net.Listener
	TLS      *tls.Config
	Config   *gemini.Server

	URL  string
	Addr string
	// contains filtered or unexported fields
}

Server is gemini server listing on a randomly chosen open port.

func NewServer

func NewServer(t *testing.T, handler gemini.Handler) *Server

NewServer returns a test server which has been started and is ready to use.

func NewUnstartedServer

func NewUnstartedServer(t *testing.T, handler gemini.Handler) *Server

NewUnstartedServer returns a server which has not been started.

func (*Server) Close

func (s *Server) Close()

Close closes the server.

func (*Server) Start

func (s *Server) Start()

Start starts an unstarted server.

Jump to

Keyboard shortcuts

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