Пример #1
0
// Called at the start of a test to setup all the various state bits that
// are needed. All tests in this module should start by calling this
// function.
func StartTest(l Logger) {
	if !streamTestOutput {
		LogBuffer = unittest.SetupBuffer()
	} else {
		logray.AddDefaultOutput("stdout://", logray.ALL)
	}
}
Пример #2
0
func Example() {
	// Setup
	buffer := unittest.SetupBuffer()
	defer buffer.DumpToStdout()

	// Unit tests go here.

	// Clear the buffer so nothing ends up being printed.
	buffer.Clear()
}
Пример #3
0
func ExamplePass() {
	// Setup
	buffer := unittest.SetupBuffer()
	defer buffer.DumpToStdout()

	// Log a bunch of stuff.
	logger := logray.New()
	fmt.Println("Expected output.")
	logger.Info("log line 1")
	logger.Info("log line 2")
	logger.Info("log line 3")

	// Clear the buffer so nothing ends up on stdout.
	buffer.Clear()

	// Output: Expected output.
}