testutil

package
v0.0.0-...-ba1c585 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Overview

Package testutil defines helpers for Syncbase tests.

Index

Constants

This section is empty.

Variables

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

	OkDbCxNames    []string = concat(validNames, longNames)
	NotOkDbCxNames []string = concat(universallyInvalidIdParts, veryLongNames)
)
View Source
var (
	OkRowKeys    []string = concat(validNames, longNames, veryLongNames)
	NotOkRowKeys []string = universallyInvalidIdParts
)

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, perms access.Permissions) syncbase.Database

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 CreateSyncgroup

func CreateSyncgroup(t testing.TB, ctx *context.T, d syncbase.Database, c syncbase.Collection, name, description string) syncbase.Syncgroup

func DefaultPerms

func DefaultPerms(tags []access.Tag, 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, rootp security.Principal, 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
	CollectionInfo *wire.StoreChangeCollectionInfo
}

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

func WatchChangeTestCollectionDelete

func WatchChangeTestCollectionDelete(cxId wire.Id, resumeMarker watch.ResumeMarker) WatchChangeTest

func WatchChangeTestCollectionPut

func WatchChangeTestCollectionPut(cxId wire.Id, allowedTags []access.Tag, perms access.Permissions, resumeMarker watch.ResumeMarker) WatchChangeTest

func WatchChangeTestRootPut

func WatchChangeTestRootPut(resumeMarker watch.ResumeMarker) WatchChangeTest

func WatchChangeTestRowDelete

func WatchChangeTestRowDelete(cxId wire.Id, rowKey string, resumeMarker watch.ResumeMarker) WatchChangeTest

func WatchChangeTestRowPut

func WatchChangeTestRowPut(cxId wire.Id, rowKey string, value interface{}, resumeMarker watch.ResumeMarker) WatchChangeTest

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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