testutil

package
v0.0.0-...-1fac7cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testutil provides test helpers for the golang-samples repo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	ProjectID string
	Dir       string
}

func ContextMain

func ContextMain(m *testing.M) (tc Context, ok bool)

ContextMain gets a test context from a TestMain function. Useful for initializing global variables before running parallel system tests. ok is false if the project is not set up properly for system tests.

func EndToEndTest

func EndToEndTest(t *testing.T) Context

EndToEndTest gets the test context, and sets the test as Parallel. The test is skipped if the GOLANG_SAMPLES_E2E_TEST environment variable is not set.

func SystemTest

func SystemTest(t *testing.T) Context

SystemTest gets the test context. The test is skipped if the GOLANG_SAMPLES_PROJECT_ID environment variable is not set.

func (Context) Path

func (tc Context) Path(p ...string) string

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner holds the result of `go build`

func BuildMain

func BuildMain(t *testing.T) *Runner

BuildMain builds the main package in the current working directory. If it doesn't build, t.Fatal is called. Test methods calling BuildMain should run Runner.Cleanup.

func (*Runner) Built

func (r *Runner) Built() bool

Built reports whether the build was successful.

func (*Runner) Cleanup

func (r *Runner) Cleanup()

Cleanup removes the built binary.

func (*Runner) Run

func (r *Runner) Run(env map[string]string, f func())

Run runs the built binary with the given environment. After f returns, the running process is shut down.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL