コード例 #1
0
ファイル: examples_test.go プロジェクト: prashantv/gostub
func ExampleStub() {
	var counter = 100

	defer gostub.Stub(&counter, 200).Reset()
	fmt.Println("Counter:", counter)
	// Output:
	// Counter: 200
}
コード例 #2
0
// Test code
func Example_stubTimeWithFunction() {
	var day = 2
	stubs := gostub.Stub(&timeNow, func() time.Time {
		return time.Date(2015, 07, day, 0, 0, 0, 0, time.UTC)
	})
	defer stubs.Reset()

	firstDay := GetDay()

	day = 3
	secondDay := GetDay()

	fmt.Printf("First day: %v, second day: %v\n", firstDay, secondDay)
	// Output:
	// First day: 2, second day: 3
}