helper

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package helper provides helper functions for testing.

Index

Constants

This section is empty.

Variables

View Source
var (
	RPCPort = 11101

	ProfilingPort = 11102

	AdminUser                             = server.DefaultAdminUser
	AdminPassword                         = server.DefaultAdminPassword
	HousekeepingInterval                  = 10 * gotime.Second
	HousekeepingCandidatesLimitPerProject = 10
	HousekeepingProjectFetchSize          = 10

	AdminTokenDuration         = "10s"
	ClientDeactivateThreshold  = "10s"
	SnapshotThreshold          = int64(10)
	SnapshotWithPurgingChanges = false
	AuthWebhookMaxWaitInterval = 3 * gotime.Millisecond
	AuthWebhookSize            = 100
	AuthWebhookCacheAuthTTL    = 10 * gotime.Second
	AuthWebhookCacheUnauthTTL  = 10 * gotime.Second
	ProjectInfoCacheSize       = 256
	ProjectInfoCacheTTL        = 5 * gotime.Second

	MongoConnectionURI     = "mongodb://localhost:27017"
	MongoConnectionTimeout = "5s"
	MongoPingTimeout       = "5s"
)

Below are the values of the Yorkie config used in the test.

Functions

func AssertEqualTreeNode added in v0.4.16

func AssertEqualTreeNode(t *testing.T, nodeA, nodeB *crdt.TreeNode)

AssertEqualTreeNode asserts that the given TreeNodes are equal.

func BuildIndexTree added in v0.4.0

func BuildIndexTree(node *json.TreeNode) *index.Tree[*crdt.TreeNode]

BuildIndexTree builds an index tree from the given block node.

func BuildTreeNode added in v0.4.0

func BuildTreeNode(node *json.TreeNode) *crdt.TreeNode

BuildTreeNode builds a crdt.TreeNode from the given tree node.

func CleanUpAllCollections added in v0.4.14

func CleanUpAllCollections(databaseName string) error

CleanUpAllCollections removes all data in every collection.

func CreateAdminCli added in v0.2.14

func CreateAdminCli(t assert.TestingT, rpcAddr string) *adminClient.Client

CreateAdminCli returns a new instance of admin cli for testing.

func CreateDummyClientWithID added in v0.4.14

func CreateDummyClientWithID(
	databaseName string,
	projectID types.ID,
	clientKey string,
	clientID types.ID,
) error

CreateDummyClientWithID creates a new dummy document with the given ID and key.

func CreateDummyDocumentWithID added in v0.4.14

func CreateDummyDocumentWithID(
	databaseName string,
	projectID types.ID,
	docID types.ID,
	docKey key.Key,
) error

CreateDummyDocumentWithID creates a new dummy document with the given ID and key.

func FindDocInfosWithID added in v0.4.14

func FindDocInfosWithID(
	databaseName string,
	docID types.ID,
) ([]*database.DocInfo, error)

FindDocInfosWithID finds the docInfos of the given projectID and docID.

func NewRangeSlice added in v0.3.3

func NewRangeSlice(start, end int) []int

NewRangeSlice returns a slice of integers from start to end.

func PosT added in v0.4.10

func PosT(change *change.Context, offset ...int) *crdt.TreeNodeID

PosT is a helper function that issues a new CRDTTreeNodeID.

func TestConfig added in v0.1.5

func TestConfig() *server.Config

TestConfig returns config for creating Yorkie instance.

func TestDBName

func TestDBName() string

TestDBName returns the name of test database with timestamp. timestamp is set only once on first call.

func TestDocKey added in v0.3.1

func TestDocKey(t testing.TB) key.Key

TestDocKey returns a new instance of document key for testing.

func TestRoot

func TestRoot() *crdt.Root

TestRoot returns the root

func TestServer added in v0.2.4

func TestServer() *server.Yorkie

TestServer returns a new instance of Yorkie for testing.

func TestSlugName added in v0.3.5

func TestSlugName(t testing.TB) string

TestSlugName returns a new instance of slug name for testing.

func TextChangeContext

func TextChangeContext(root *crdt.Root) *change.Context

TextChangeContext returns the context of test change.

func TimeT added in v0.4.10

func TimeT(change *change.Context) *time.Ticket

TimeT is a helper function that issues a new TimeTicket

func ToDiagnostic added in v0.4.0

func ToDiagnostic(node *crdt.TreeNode) string

ToDiagnostic is a helper function that converts the given node to a diagnostic string.

func TokensEqualBetween added in v0.4.12

func TokensEqualBetween(t assert.TestingT, tree *index.Tree[*crdt.TreeNode], from, to int, expected []string) bool

TokensEqualBetween is a helper function that checks the tokens between the given indexes.

func WaitForServerToStart added in v0.4.15

func WaitForServerToStart(addr string) error

WaitForServerToStart waits for the server to start.

Types

This section is empty.

Jump to

Keyboard shortcuts

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