Documentation
¶
Index ¶
- func FixedTempDir(t testing.TB, name string) string
- func TempTestDir(t testing.TB, prefix string) string
- func TestLoggerBackend(t testing.TB, name string) func(subsys string) slog.Logger
- func TestLoggerSys(t testing.TB, sys string) slog.Logger
- type MockPayClient
- func (pc *MockPayClient) DecodeInvoice(_ context.Context, invoice string) (clientintf.DecodedInvoice, error)
- func (pc *MockPayClient) DefaultDecodeInvoice(invoice string) (clientintf.DecodedInvoice, error)
- func (pc *MockPayClient) GetInvoice(ctx context.Context, mat int64, cb func(int64)) (string, error)
- func (pc *MockPayClient) HookDecodeInvoice(hook func(string) (clientintf.DecodedInvoice, error))
- func (pc *MockPayClient) HookGetInvoice(hook func(int64, func(int64)) (string, error))
- func (pc *MockPayClient) HookIsPayCompleted(hook func(string) (int64, error))
- func (pc *MockPayClient) HookPayInvoice(hook func(string) (int64, error))
- func (pc *MockPayClient) HookTrackInvoice(hook func(string, int64) (int64, error))
- func (pc *MockPayClient) IsInvoicePaid(context.Context, int64, string) error
- func (pc *MockPayClient) IsPaymentCompleted(_ context.Context, invoice string) (int64, error)
- func (pc *MockPayClient) PayInvoice(_ context.Context, invoice string) (int64, error)
- func (pc *MockPayClient) PayInvoiceAmount(_ context.Context, invoice string, _ int64) (int64, error)
- func (pc *MockPayClient) PayScheme() string
- func (pc *MockPayClient) TrackInvoice(ctx context.Context, inv string, minMAtoms int64) (int64, error)
- type TestLogBackend
- type TestLogBackendOption
- type UnsafeTestInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixedTempDir ¶ added in v0.1.4
FixedTempDir creates a temp dir with a fixed name (without any random parts) and cleans it up on a successful test. The dir is cleared before this function returns.
func TempTestDir ¶ added in v0.1.4
TempTestDir returns a temp dir for a test that only gets cleaned up if the test does not fail.
func TestLoggerBackend ¶
TestLoggerBackend returns a function that generates loggers for subsystems, all of which log by calling t.Log.
Types ¶
type MockPayClient ¶ added in v0.1.7
type MockPayClient struct {
// contains filtered or unexported fields
}
MockPayClient fulfills the clientintf.PaymentClient interface, while allowing to fail certain calls. It is used for tests.
It behaves as the free payment client, except for hooked calls.
func (*MockPayClient) DecodeInvoice ¶ added in v0.1.7
func (pc *MockPayClient) DecodeInvoice(_ context.Context, invoice string) (clientintf.DecodedInvoice, error)
func (*MockPayClient) DefaultDecodeInvoice ¶ added in v0.1.7
func (pc *MockPayClient) DefaultDecodeInvoice(invoice string) (clientintf.DecodedInvoice, error)
DefaultDecodeInvoice is the default behavior of the MockPayClient DecodeInvoice(). Useful when DecodeInvoice is hooked and the default behavior is desired for a particular invoice.
func (*MockPayClient) GetInvoice ¶ added in v0.1.7
func (*MockPayClient) HookDecodeInvoice ¶ added in v0.1.7
func (pc *MockPayClient) HookDecodeInvoice(hook func(string) (clientintf.DecodedInvoice, error))
func (*MockPayClient) HookGetInvoice ¶ added in v0.1.7
func (pc *MockPayClient) HookGetInvoice(hook func(int64, func(int64)) (string, error))
func (*MockPayClient) HookIsPayCompleted ¶ added in v0.1.7
func (pc *MockPayClient) HookIsPayCompleted(hook func(string) (int64, error))
func (*MockPayClient) HookPayInvoice ¶ added in v0.1.7
func (pc *MockPayClient) HookPayInvoice(hook func(string) (int64, error))
func (*MockPayClient) HookTrackInvoice ¶ added in v0.1.8
func (pc *MockPayClient) HookTrackInvoice(hook func(string, int64) (int64, error))
func (*MockPayClient) IsInvoicePaid ¶ added in v0.1.7
func (*MockPayClient) IsPaymentCompleted ¶ added in v0.1.7
func (*MockPayClient) PayInvoice ¶ added in v0.1.7
func (*MockPayClient) PayInvoiceAmount ¶ added in v0.1.7
func (*MockPayClient) PayScheme ¶ added in v0.1.7
func (pc *MockPayClient) PayScheme() string
func (*MockPayClient) TrackInvoice ¶ added in v0.1.8
type TestLogBackend ¶ added in v0.1.8
type TestLogBackend struct {
// contains filtered or unexported fields
}
TestLogBackend is a slog backend suitable for using with tests.
func NewTestLogBackend ¶
func NewTestLogBackend(t testing.TB, opts ...TestLogBackendOption) *TestLogBackend
NewTestLogBackend returns a log backend that can be used as an io.Writer to write logs to during a test.
func (*TestLogBackend) NamedSubLogger ¶ added in v0.1.8
NamedSubLogger returns a sub logger backend suitable for passing to clients, prefixed with the specified name.
type TestLogBackendOption ¶ added in v0.1.8
type TestLogBackendOption func(t *TestLogBackend)
func WithMiddlewareWriter ¶ added in v0.1.8
func WithMiddlewareWriter(w io.Writer) TestLogBackendOption
func WithShowLog ¶ added in v0.1.8
func WithShowLog(showLog bool) TestLogBackendOption
type UnsafeTestInterface ¶ added in v0.1.8
type UnsafeTestInterface struct { // SendUserRM send a custom RM to a remote user. SendUserRM func(uid clientintf.UserID, msg interface{}) error // QueueUserRM queues a custom RM to a remote user. QueueUserRM func(uid clientintf.UserID, msg interface{}) error }
UnsafeTestInterface is an interface used for exposing internal methods to integration tests.
This struct is subject to change without notice and is should not be used outside internal/* packages.