Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.
/ neo Public archive

Time, network and other environment simulation in go

License

Notifications You must be signed in to change notification settings

gotd/neo

Folders and files

NameName
Last commit message
Last commit date
Sep 11, 2023
Dec 22, 2020
Dec 22, 2020
Dec 22, 2020
Jul 19, 2019
Dec 22, 2020
Dec 22, 2020
Dec 22, 2020
May 8, 2023
May 8, 2023
Dec 22, 2020
Apr 7, 2021
Dec 22, 2020
Jul 25, 2019
Dec 27, 2021
Dec 27, 2021
Dec 27, 2021
Dec 27, 2021
Dec 27, 2021

Repository files navigation

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
}