Documentation
¶
Overview ¶
Package fake provides a fake client for testing. It implements the client.Client interface but saves all entries in memory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a fake client that stores all pushed entries in memory.
func New ¶
func New() *Client
New creates a new Client. It is safe to call concurrently from multiple goroutines.
func (*Client) AssertEntries ¶
AssertEntries asserts that the Client has the given entries. It handles the locking of the Client for reading and unlocking it after the assertion. It is safe to call concurrently from multiple goroutines.
The entries are compared so that the timestamps are within a second of this function being called and all other fields are equal.
Like the testify/assert package, this function returns true if the assertion is successful.
func (*Client) Close ¶
func (client *Client) Close()
Close unlocks the Client for reading. Note that if there are multiple open read locks due to Entries being called multiple times, Close will only release one of them. Each call to Entries should therefore be followed by a call to Close. It is safe to call concurrently from multiple goroutines.
func (*Client) Entries ¶
Entries returns all entries that have been pushed to the Client. Entries should not be modified by the caller. It locks the Client for reading, so new entries cannot be pushed to the Client until after Close is called. It is safe to call concurrently from multiple goroutines.