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

package testutil

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

Index

Package Files

assertions.go context.go spantest.go

Constants

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 InsertFinalizedInvocationWithInclusions Uses

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

InsertFinalizedInvocationWithInclusions returns mutations to insert a finalized invocation with inclusions.

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, ct time.Time, extraValues map[string]interface{}) *spanner.Mutation

InsertInvocation returns a spanner mutation that inserts an invocation.

func InsertInvocationWithInclusions Uses

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

InsertInvocationWithInclusions returns mutations to insert an invocation with inclusions.

func InsertTestExonerations Uses

func InsertTestExonerations(invID span.InvocationID, testID string, variant *typepb.Variant, count int) []*spanner.Mutation

InsertTestExonerations returns spanner mutations to insert test exonerations.

func InsertTestResults Uses

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

InsertTestResults returns spanner mutations to insert test results

func LogQueryResults Uses

func LogQueryResults(ctx context.Context, st spanner.Statement)

LogQueryResults executes the statement and logs results. Useful to debug failing tests.

func MakeTestResults Uses

func MakeTestResults(invID, testID 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 ShouldHaveAppStatus Uses

func ShouldHaveAppStatus(actual interface{}, expected ...interface{}) string

ShouldHaveAppStatus asserts that error `actual` has an application-specific status and it matches the expectations. See ShouldBeLikeStatus for the format of `expected`. See appstatus package for application-specific statuses.

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 23 packages (graph). Updated 2020-01-29. Refresh now. Tools for package owners.