luci: Index | Files

package testutil

import ""


Package Files

context.go spantest.go


const IntegrationTestEnvVar = "INTEGRATION_TESTS"

IntegrationTestEnvVar is the name of the environment variable which controls whether spanner tests are executed. The value must be "1" for integration tests to run.

func CombineMutations Uses

func CombineMutations(msSlice ...[]*spanner.Mutation) []*spanner.Mutation

CombineMutations concatenates mutations

func InsertInclusion Uses

func InsertInclusion(including, included span.InvocationID) *spanner.Mutation

InsertInclusion returns a spanner mutation that inserts an inclusion.

func InsertInvocation Uses

func InsertInvocation(id span.InvocationID, state pb.Invocation_State, updateToken string, ct time.Time) *spanner.Mutation

InsertInvocation returns a spanner mutation that inserts an invocation.

func InsertInvocationWithInclusions Uses

func InsertInvocationWithInclusions(id span.InvocationID, included ...span.InvocationID) []*spanner.Mutation

InsertInvocationIncl returns mutations to insert an invocation with inclusions.

func InsertTestResults Uses

func InsertTestResults(trs []*pb.TestResult) []*spanner.Mutation

InsertTestResults returns spanner mutations to insert test results

func MakeTestResults Uses

func MakeTestResults(invID, testPath string, statuses ...pb.TestStatus) []*pb.TestResult

MakeTestResults creates test results.

func MustApply Uses

func MustApply(ctx context.Context, ms ...*spanner.Mutation)

MustApply applies the mutations to the spanner client in the context. Asserts that application succeeds.

func MustReadRow Uses

func MustReadRow(ctx context.Context, table string, key spanner.Key, ptrMap map[string]interface{})

MustReadRow is a shortcut to do a single row read in a single transaction using the current client, and assert success.

func RunIntegrationTests Uses

func RunIntegrationTests() bool

RunIntegrationTests returns true if integration tests should run.

func SpannerTestContext Uses

func SpannerTestContext(tb testing.TB) context.Context

SpannerTestContext returns a context for testing code that talks to Spanner. Skips the test if integration tests are not enabled.

Tests that use Spanner must not call t.Parallel().

func SpannerTestMain Uses

func SpannerTestMain(m *testing.M)

SpannerTestMain is a test main function for packages that have tests that talk to spanner. It creates/destroys a temporary spanner database before/after running tests.

This function never returns. Instead it calls os.Exit with the value returned by m.Run().

func TestingContext Uses

func TestingContext() context.Context

TestingContext returns a context to be used in tests.

Package testutil imports 16 packages (graph). Updated 2019-11-20. Refresh now. Tools for package owners.