testutil

package
v0.0.0-...-ff5f600 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2016 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package testutil defines helpers for Syncbase tests.

Index

Constants

This section is empty.

Variables

View Source
var (
	OkAppUserBlessings    []string = validBlessingPatterns
	NotOkAppUserBlessings []string = concat(universallyInvalidNames, invalidBlessingPatterns, longNames)

	OkDbCxNames    []string = validIdentifiers
	NotOkDbCxNames []string = concat(universallyInvalidNames, longNames, invalidIdentifiers)
)
View Source
var (
	OkRowKeys    []string = concat(validIdentifiers, invalidIdentifiers, longNames)
	NotOkRowKeys []string = universallyInvalidNames
)

Functions

func CheckExec

func CheckExec(t testing.TB, ctx *context.T, db syncbase.DatabaseHandle, q string, wantHeaders []string, wantResults [][]*vom.RawBytes)

func CheckExecError

func CheckExecError(t testing.TB, ctx *context.T, db syncbase.DatabaseHandle, q string, wantErrorID verror.ID)

func CheckScan

func CheckScan(t testing.TB, ctx *context.T, c syncbase.Collection, r syncbase.RowRange, wantKeys []string, wantValues []interface{})

func CheckWatch

func CheckWatch(t testing.TB, wstream syncbase.WatchStream, changes []WatchChangeTest)

CheckWatch checks that the sequence of elements from the watch stream starts with the given slice of watch changes.

func CreateCollection

func CreateCollection(t testing.TB, ctx *context.T, d syncbase.Database, name string) syncbase.Collection

func CreateDatabase

func CreateDatabase(t testing.TB, ctx *context.T, s syncbase.Service, name string) syncbase.Database

func CxId

func CxId(name string) wire.Id

func DbId

func DbId(name string) wire.Id

TODO(sadovsky): Standardize on a small set of constants and helper functions to share across all Syncbase tests. Currently, our 'featuretests' tests use a different set of helpers from our other unit tests.

func DefaultPerms

func DefaultPerms(patterns ...string) access.Permissions

func DefaultSchema

func DefaultSchema(version int32) *syncbase.Schema

func Fatal

func Fatal(t testing.TB, args ...interface{})

func Fatalf

func Fatalf(t testing.TB, format string, args ...interface{})

func NewCtx

func NewCtx(ctx *context.T, rootp security.Principal, suffix string) *context.T

Creates a new context object with blessing "root:<suffix>", configured to present this blessing when acting as a server as well as when acting as a client and talking to a server that presents a blessing rooted at "root". TODO(sadovsky): Switch unit tests to v23test.Shell, then delete this.

func ScanMatches

func ScanMatches(ctx *context.T, c syncbase.Collection, r syncbase.RowRange, wantKeys []string, wantValues []interface{}) error

func SetupOrDie

func SetupOrDie(perms access.Permissions) (clientCtx *context.T, serverName string, cleanup func())

TODO(sadovsky): Drop the 'perms' argument. The only client that passes non-nil, syncgroup_test.go, should use SetupOrDieCustom instead.

func SetupOrDieCustom

func SetupOrDieCustom(clientSuffix, serverSuffix string, perms access.Permissions) (ctx, clientCtx *context.T, serverName string, rootp security.Principal, cleanup func())

TODO(sadovsky): Switch unit tests to v23test.Shell, then delete this.

func TestCreate

func TestCreate(t *testing.T, ctx *context.T, i interface{})

TestCreate tests that object creation works as expected.

func TestCreateNameValidation

func TestCreateNameValidation(t *testing.T, ctx *context.T, i interface{}, okNames, notOkNames []string)

Tests that Create() checks name validity.

func TestDestroy

func TestDestroy(t *testing.T, ctx *context.T, i interface{})

TestDestroy tests that object destruction works as expected.

func TestListChildIds

func TestListChildIds(t *testing.T, ctx *context.T, i interface{}, blessings, names []string)

func TestPerms

func TestPerms(t *testing.T, ctx *context.T, ac util.AccessController)

TestPerms tests that {Set,Get}Permissions work as expected. TODO(sadovsky): All Vanadium {Set,Get}Permissions tests ought to share this test implementation. :) Mirrors v.io/groups/x/ref/services/groups/internal/server/server_test.go.

func WatchChangeEq

func WatchChangeEq(got *syncbase.WatchChange, want *WatchChangeTest) (eq bool)

WatchChangeEq returns whether *want and *got represent the same value.

Types

type WatchChangeTest

type WatchChangeTest struct {
	syncbase.WatchChange
	ValueBytes *vom.RawBytes
}

A WatchChangeTest is a syncbase.WatchChange that has a public ValueBytes field, to allow tests to set it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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