tie / neo

Time, network and other environment simulation in go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

neo

Package neo implements side effects (network, time) simulation for testing.

Wake up, Neo...

Replace side effects with explicit dependencies so you can sleep at night. Abuse time and network simulation in unit tests and reduce flaky, complicated and long integration tests.

package main

import (
	"fmt"
	"time"

	"github.com/gotd/neo"
)

func main() {
	// Set to current time.
	t := neo.NewTime(time.Now())

	// Travel to future.
	fmt.Println(t.Travel(time.Hour * 2).Format(time.RFC3339))
	// 2019-07-19T16:42:09+03:00

	// Back to past.
	fmt.Println(t.Travel(time.Hour * -2).Format(time.RFC3339))
	// 2019-07-19T14:42:09+03:00
}

About

Time, network and other environment simulation in go

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 97.7%Language:Shell 2.0%Language:Makefile 0.3%