Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 4.0% on proxy.golang.org
Top 0.3% dependent packages on proxy.golang.org
Top 0.3% dependent repos on proxy.golang.org
Top 9.8% forks on proxy.golang.org
Top 0.2% docker downloads on proxy.golang.org

proxy.golang.org : github.com/tilinna/clock

Package clock implements a library for mocking time. Include a Clock variable on your application and initialize it with a Realtime() by default. Then use the Clock for all time-related API calls. So instead of time.NewTimer(), say myClock.NewTimer(). On a test setup, override or inject the variable with a Mock instance and use it to control how the time behaves during each test phase. To mock context.WithTimeout and context.WithDeadline, use the included Context, TimeoutContext and DeadlineContext methods. The Context method is also useful in cases where you need to pass a Clock via an 'func(ctx Context, ..)' API you can't change yourself. The FromContext method will then return the associated Clock instance. Alternatively, use the context'ed methods like Sleep(ctx) directly. All methods are safe for concurrent use.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/tilinna/clock
Keywords: context, go, golang, mocking, testing, time
License: MIT
Latest release: over 3 years ago
First release: about 6 years ago
Namespace: github.com/tilinna
Dependent packages: 184
Dependent repositories: 766
Stars: 11 on GitHub
Forks: 3 on GitHub
Docker dependents: 187
Docker downloads: 788,457,253
See more repository details: repos.ecosyste.ms
Last synced: 20 days ago

    Loading...
    Readme
    Loading...