timeutils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RealTimeProvider = sync.OnceValue(func() *realTimeProvider {
	return &realTimeProvider{}
})

Functions

This section is empty.

Types

type TimeProvider

type TimeProvider interface {
	Now() time.Time
}

type TimeProviderMock

type TimeProviderMock struct {
	// NowFunc mocks the Now method.
	NowFunc func() time.Time
	// contains filtered or unexported fields
}

TimeProviderMock is a mock implementation of TimeProvider.

func TestSomethingThatUsesTimeProvider(t *testing.T) {

	// make and configure a mocked TimeProvider
	mockedTimeProvider := &TimeProviderMock{
		NowFunc: func() time.Time {
			panic("mock out the Now method")
		},
	}

	// use mockedTimeProvider in code that requires TimeProvider
	// and then make assertions.

}

func (*TimeProviderMock) Now

func (mock *TimeProviderMock) Now() time.Time

Now calls NowFunc.

func (*TimeProviderMock) NowCalls

func (mock *TimeProviderMock) NowCalls() []struct {
}

NowCalls gets all the calls that were made to Now. Check the length with:

len(mockedTimeProvider.NowCalls())

Jump to

Keyboard shortcuts

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