testtime provides time.Now for testing.

Overview

testtime

pkg.go.dev

testtime provides time.Now for testing.

WARNING: This package is an experimental project.

https://play.golang.org/p/ML5nhtXLOWA

package main

import (
	"fmt"
	"time"
	_ "unsafe" // for go:linkname

	"github.com/tenntenn/testtime"
)

// replace time.Now
//go:linkname now time.Now
func now() time.Time {
	return testtime.Now()
}

func main() {
	func() {
		// set zero value
		testtime.Set(time.Time{})
		// true
		fmt.Println(time.Now().IsZero())
	}()
	// false
	fmt.Println(time.Now().IsZero())
}
You might also like...
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Minimal and Beautiful Go testing framework
Minimal and Beautiful Go testing framework

Goblin A Mocha like BDD testing framework written in Go that requires no additional dependencies. Requires no extensive documentation nor complicated

A Comprehensive Coverage Testing System for The Go Programming Language
A Comprehensive Coverage Testing System for The Go Programming Language

goc 中文页 | goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing c

Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.

GoConvey is awesome Go testing Welcome to GoConvey, a yummy Go testing tool for gophers. Works with go test. Use it in the terminal or browser accordi

Testing API Handler written in Golang.

Gofight API Handler Testing for Golang Web framework. Support Framework Http Handler Golang package http provides HTTP client and server implementatio

Library created for testing JSON against patterns.

Gomatch Library created for testing JSON against patterns. The goal was to be able to validate JSON focusing only on parts essential in given test cas

Testing framework for Go. Allows writing self-documenting tests/specifications, and executes them concurrently and safely isolated. [UNMAINTAINED]

GoSpec GoSpec is a BDD-style testing framework for the Go programming language. It allows writing self-documenting tests/specs, and executes them in p

A collection of packages to augment the go testing package and support common patterns.

gotest.tools A collection of packages to augment testing and support common patterns. Usage With Go modules enabled (go1.11+) $ go get gotest.tools/v3

End-to-end HTTP and REST API testing for Go.

httpexpect Concise, declarative, and easy to use end-to-end HTTP and REST API testing for Go (golang). Basically, httpexpect is a set of chainable bui

Comments
  • Release for v0.3.0

    Release for v0.3.0

    This pull request is for the next release as v0.3.0 created by tagpr. Merging it will tag v0.3.0 to the merge commit and create a GitHub release.

    You can modify this branch "tagpr-from-v0.2.2" directly before merging if you want to change the next version number or other files for the release.

    How to change the next version as you like

    There are two ways to do it.

    • Version file
      • Edit and commit the version file specified in the .tagpr configuration file to describe the next version
      • If you want to use another version file, edit the configuration file.
    • Labels convention
      • Add labels to this pull request like "tagpr:minor" or "tagpr:major"
      • If no conventional labels are added, the patch version is incremented as is.

    What's Changed

    • Add tagpr workflow by @tenntenn in https://github.com/tenntenn/testtime/pull/9
    • Remo function name from map keys by @tenntenn in https://github.com/tenntenn/testtime/pull/8

    Full Changelog: https://github.com/tenntenn/testtime/compare/v0.2.2...v0.3.0

    tagpr 
    opened by github-actions[bot] 0
Releases(v0.2.2)
Owner
Takuya Ueda
Go engineer / Gopher artist
Takuya Ueda
A yaml data-driven testing format together with golang testing library

Specimen Yaml-based data-driven testing Specimen is a yaml data format for data-driven testing. This enforces separation between feature being tested

Design it, Run it 1 Nov 24, 2022
A next-generation testing tool. Orion provides a powerful DSL to write and automate your acceptance tests

Orion is born to change the way we implement our acceptance tests. It takes advantage of HCL from Hashicorp t o provide a simple DSL to write the acceptance tests.

Wesovi Labs 45 Aug 31, 2022
Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio Fortio (Φορτίο) started as, and is, Istio's load testing tool and now graduated to be its own project. Fortio is also used by, among others, Me

Fortio (Φορτίο) 2.8k Nov 28, 2022
:exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions

Package assert Package assert is a Basic Assertion library used along side native go testing Installation Use go get. go get github.com/go-playground/

Go Playgound 50 Nov 26, 2022
Expressive end-to-end HTTP API testing made easy in Go

baloo Expressive and versatile end-to-end HTTP API testing made easy in Go (golang), built on top of gentleman HTTP client toolkit. Take a look to the

Tom 746 Nov 19, 2022
Simple Go snapshot testing

Incredibly simple Go snapshot testing: cupaloy takes a snapshot of your test output and compares it to a snapshot committed alongside your tests. If t

Bradley Kemp 240 Nov 24, 2022
Clean database for testing, inspired by database_cleaner for Ruby

DbCleaner Clean database for testing, inspired by database_cleaner for Ruby. It uses flock syscall under the hood to make sure the test can runs in pa

Scott Le 146 Nov 17, 2022
Golang HTTP client testing framework

flute Golang HTTP client testing framework Presentation https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework Overview flute is the

Shunsuke Suzuki 17 Sep 27, 2022
API testing framework inspired by frisby-js

frisby REST API testing framework inspired by frisby-js, written in Go Proposals I'm starting to work on frisby again with the following ideas: Read s

_Hofstadter 274 Sep 27, 2022
Mutation testing for Go source code

go-mutesting go-mutesting is a framework for performing mutation testing on Go source code. Its main purpose is to find source code, which is not cove

Markus Zimmermann 563 Nov 18, 2022