notification

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPreviewer = &Previewer{
	Prefix: "/emailpreviews",
}

DefaultPreviewer is the default previewer.

Functions

This section is empty.

Types

type HermesRenderer

type HermesRenderer struct {
	Template *hermes.Hermes
}

HermesRenderer takes a hermes template and uses that to render a message.

func (*HermesRenderer) Render

func (r *HermesRenderer) Render(tmpl hermes.Email) (string, string, error)

Render returns the plain text email body, html email body, and an error.

type Message

type Message struct {
	To         []string
	From       string
	FromPretty string
	Body       string
	BodyHTML   string
	Subject    string
}

Message is basic structure for notification system.

type Previewer

type Previewer struct {
	Data      map[string]hermes.Email
	Prefix    string
	URLPrefix string
	Renderer  Renderer
	// contains filtered or unexported fields
}

Previewer is an HTTP handler that renders previews of email templates.

func (*Previewer) Register

func (p *Previewer) Register(name string, email hermes.Email)

Register registers a an email template with the given name.

func (*Previewer) ServeHTTP

func (p *Previewer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP builds the routes if necessary and serves up the request.

type Renderer

type Renderer interface {
	// Render returns the plain text email body, html email body, and an error.
	Render(tmpl hermes.Email) (string, string, error)
}

Renderer is an interface for rendering emails.

type Sender

type Sender interface {
	// Send is a function that sends an email
	Send(msg Message) error
}

Sender is an interface that sends an email.

type SenderMock

type SenderMock struct {
	// SendFunc mocks the Send method.
	SendFunc func(msg Message) error
	// contains filtered or unexported fields
}

SenderMock is a mock implementation of Sender.

    func TestSomethingThatUsesSender(t *testing.T) {

        // make and configure a mocked Sender
        mockedSender := &SenderMock{
            SendFunc: func(msg Message) error {
	               panic("TODO: mock out the Send method")
            },
        }

        // TODO: use mockedSender in code that requires Sender
        //       and then make assertions.

    }

func (*SenderMock) Send

func (mock *SenderMock) Send(msg Message) error

Send calls SendFunc.

func (*SenderMock) SendCalls

func (mock *SenderMock) SendCalls() []struct {
	Msg Message
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedSender.SendCalls())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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