Documentation ¶
Overview ¶
Package testutil defines helpers for Syncbase tests.
Index ¶
- Variables
- func CheckExec(t testing.TB, ctx *context.T, db syncbase.DatabaseHandle, q string, ...)
- func CheckExecError(t testing.TB, ctx *context.T, db syncbase.DatabaseHandle, q string, ...)
- func CheckScan(t testing.TB, ctx *context.T, c syncbase.Collection, r syncbase.RowRange, ...)
- func CheckWatch(t testing.TB, wstream syncbase.WatchStream, changes []WatchChangeTest)
- func CreateCollection(t testing.TB, ctx *context.T, d syncbase.Database, name string) syncbase.Collection
- func CreateDatabase(t testing.TB, ctx *context.T, s syncbase.Service, name string, ...) syncbase.Database
- func CreateSyncgroup(t testing.TB, ctx *context.T, d syncbase.Database, c syncbase.Collection, ...) syncbase.Syncgroup
- func DefaultPerms(tags []access.Tag, patterns ...string) access.Permissions
- func DefaultSchema(version int32) *syncbase.Schema
- func Fatal(t testing.TB, args ...interface{})
- func Fatalf(t testing.TB, format string, args ...interface{})
- func NewCtx(ctx *context.T, rootp security.Principal, suffix string) *context.T
- func ScanMatches(ctx *context.T, c syncbase.Collection, r syncbase.RowRange, wantKeys []string, ...) error
- func SetupOrDie(perms access.Permissions) (clientCtx *context.T, serverName string, cleanup func())
- func SetupOrDieCustom(clientSuffix, serverSuffix string, perms access.Permissions) (ctx, clientCtx *context.T, serverName string, rootp security.Principal, ...)
- func TestCreate(t *testing.T, ctx *context.T, i interface{})
- func TestCreateNameValidation(t *testing.T, ctx *context.T, i interface{}, okNames, notOkNames []string)
- func TestDestroy(t *testing.T, ctx *context.T, i interface{})
- func TestListChildIds(t *testing.T, ctx *context.T, rootp security.Principal, i interface{}, ...)
- func TestPerms(t *testing.T, ctx *context.T, ac util.AccessController)
- func WatchChangeEq(got *syncbase.WatchChange, want *WatchChangeTest) (eq bool)
- type WatchChangeTest
- func WatchChangeTestCollectionDelete(cxId wire.Id, resumeMarker watch.ResumeMarker) WatchChangeTest
- func WatchChangeTestCollectionPut(cxId wire.Id, allowedTags []access.Tag, perms access.Permissions, ...) WatchChangeTest
- func WatchChangeTestRootPut(resumeMarker watch.ResumeMarker) WatchChangeTest
- func WatchChangeTestRowDelete(cxId wire.Id, rowKey string, resumeMarker watch.ResumeMarker) WatchChangeTest
- func WatchChangeTestRowPut(cxId wire.Id, rowKey string, value interface{}, ...) WatchChangeTest
Constants ¶
This section is empty.
Variables ¶
var ( OkAppUserBlessings []string = concat(validBlessingPatterns, longNames) NotOkAppUserBlessings []string = concat(universallyInvalidIdParts, invalidBlessingPatterns, veryLongNames) OkDbCxNames []string = concat(validNames, longNames) NotOkDbCxNames []string = concat(universallyInvalidIdParts, veryLongNames) )
var ( OkRowKeys []string = concat(validNames, longNames, veryLongNames) NotOkRowKeys []string = universallyInvalidIdParts )
Functions ¶
func CheckExecError ¶
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 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 DefaultPerms ¶
func DefaultPerms(tags []access.Tag, patterns ...string) access.Permissions
func DefaultSchema ¶
func NewCtx ¶
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 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 ¶
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 ¶
TestDestroy tests that object destruction works as expected.
func TestListChildIds ¶
func TestPerms ¶
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