problemrectest

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package problemrectest gives tests a local journal test socket for the problem records of intuneme. Only tests import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(t testing.TB, fields map[string]string, class, version, code string) problems.Detail

Check fails the test when fields is not a valid intuneme record of class at version, or when its code differs from code (empty for a panic). It returns the validated detail.

func Listen

func Listen(t testing.TB) (path string, next func() map[string]string)

Listen binds a test socket and returns its path and a function that reads the next record. next fails the test when no datagram comes within 5 seconds, or when the datagram does not decode.

Types

type Socket

type Socket struct {
	// Path is the socket path for problems.WithSocket.
	Path string
	// contains filtered or unexported fields
}

Socket is a unixgram test socket that stands in for the journal socket.

func NewSocket

func NewSocket(t testing.TB) *Socket

NewSocket binds a unixgram socket in t.TempDir. It closes at the end of the test.

func Use

func Use(t testing.TB, version string) *Socket

Use makes the process-wide recorder for version, writing to a new test socket, and restores the old recorder at the end of the test.

func (*Socket) ExpectNone

func (s *Socket) ExpectNone(wait time.Duration)

ExpectNone fails the test when a datagram arrives within wait. A record is sent before the call that writes it returns, so a short wait is enough.

func (*Socket) Next

func (s *Socket) Next() map[string]string

Next reads 1 datagram, with a deadline of 5 seconds, and decodes it with problems.DecodeEntry.

Jump to

Keyboard shortcuts

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