예제 #1
0
// Test code
func Example_stubTimeWithConstant() {
	stubs := gostub.StubFunc(&timeNow, time.Date(2015, 07, 2, 0, 0, 0, 0, time.UTC))
	defer stubs.Reset()

	fmt.Println("Day:", GetDay())
	// Output:
	// Day: 2
}
예제 #2
0
func ExampleStubFunc() {
	var osHostname = os.Hostname

	defer gostub.StubFunc(&osHostname, "fakehost", nil).Reset()
	host, err := osHostname()

	fmt.Println("Host:", host, "err:", err)
	// Output:
	// Host: fakehost err: <nil>
}