luci: go.chromium.org/luci/resultdb/internal/testutil Index | Files | Directories

package testutil

import "go.chromium.org/luci/resultdb/internal/testutil"

Index

Package Files

context.go spantest.go

Constants

const (
    // 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.
    IntegrationTestEnvVar = "INTEGRATION_TESTS"

    // RedisTestEnvVar is the name of the environment variable which controls
    // whether tests will attempt to connect to *local* Redis at port 6379.
    // The value must be "1" to connect to Redis.
    //
    // Note that this mode does not support running multiple test binaries in
    // parallel, e.g. `go test ./...`.
    // This could be mitigated by using different Redis databases in different
    // test binaries, but the default limit is only 16.
    RedisTestEnvVar = "INTEGRATION_TESTS_REDIS"
)

func CombineMutations Uses

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

CombineMutations concatenates mutations

func MustApply Uses

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

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

func MustNotFindRow Uses

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

MustNotFindRow is a shortcut to do a single row read in a single transaction using the current client, and assert the row was not found.

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 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.

Directories

PathSynopsis
insertPackage insert implements functions to insert rows for testing purposes.

Package testutil imports 20 packages (graph). Updated 2020-10-01. Refresh now. Tools for package owners.