testutil

package
v5.0.0-...-0775b3c Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testutil contains shared test functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAfter

func AssertAfter(t *testing.T, t1, t2 time.Time)

func AssertDeepEquals

func AssertDeepEquals(t *testing.T, values ...any)

func AssertEmptyString

func AssertEmptyString(t *testing.T, s string)

func AssertEqualsInAnyOrder

func AssertEqualsInAnyOrder(t *testing.T, actual []string, expected []string)

func AssertError

func AssertError(t *testing.T, err error)

func AssertErrorMessageContains

func AssertErrorMessageContains(t *testing.T, err error, msg string, args ...any)

func AssertFalse

func AssertFalse(t *testing.T, b bool)

func AssertIntEqual

func AssertIntEqual(t *testing.T, ai, ei int)

func AssertLen

func AssertLen(t *testing.T, x any, el int)

func AssertMajorVersionInHandshake

func AssertMajorVersionInHandshake(t *testing.T, handshake []byte, major byte)

func AssertNeo4jError

func AssertNeo4jError(t *testing.T, err error)

func AssertNextOnlyError

func AssertNextOnlyError(t *testing.T, rec *db.Record, sum *db.Summary, err error)

func AssertNextOnlyRecord

func AssertNextOnlyRecord(t *testing.T, rec *db.Record, sum *db.Summary, err error)

func AssertNextOnlySummary

func AssertNextOnlySummary(t *testing.T, rec *db.Record, sum *db.Summary, err error)

func AssertNil

func AssertNil(t *testing.T, x any)

func AssertNoError

func AssertNoError(t *testing.T, err error)

func AssertNotNil

func AssertNotNil(t *testing.T, x any)

func AssertPanics

func AssertPanics(t *testing.T, f func())

func AssertSameType

func AssertSameType(t *testing.T, x, y any)

func AssertSliceEqual

func AssertSliceEqual(t *testing.T, x, y any)

func AssertStringContain

func AssertStringContain(t *testing.T, s, sub string)

func AssertStringEqual

func AssertStringEqual(t *testing.T, as, es string)

func AssertStringNotEmpty

func AssertStringNotEmpty(t *testing.T, s string)

func AssertTrue

func AssertTrue(t *testing.T, b bool)

func AssertVersionInHandshake

func AssertVersionInHandshake(t *testing.T, handshake []byte, major, minor byte)

func AssertWriteSucceeds

func AssertWriteSucceeds(t *testing.T, w io.Writer, b []byte)

Types

type ConnFake

type ConnFake struct {
	Name               string
	ConnectionVersion  db.ProtocolVersion
	Alive              bool
	Birth              time.Time
	Table              *idb.RoutingTable
	Err                error
	Id                 int
	TxBeginErr         error
	TxBeginHandle      idb.TxHandle
	RunErr             error
	RunStream          idb.StreamHandle
	RunTxErr           error
	RunTxStream        idb.StreamHandle
	Nexts              []Next
	Bookm              string
	TxCommitErr        error
	TxCommitHook       func()
	TxRollbackErr      error
	ConsumeSum         *db.Summary
	ConsumeErr         error
	ConsumeHook        func()
	RecordedTxs        []RecordedTx // Appended to by Run/TxBegin
	BufferErr          error
	BufferHook         func()
	DatabaseName       string
	Idle               time.Time
	ServerVersionValue string
	ForceResetHook     func()
}

func (*ConnFake) Birthdate

func (c *ConnFake) Birthdate() time.Time

func (*ConnFake) Bookmark

func (c *ConnFake) Bookmark() string

func (*ConnFake) Buffer

func (*ConnFake) Close

func (c *ConnFake) Close(ctx context.Context)

func (*ConnFake) Connect

func (c *ConnFake) Connect(context.Context, int, map[string]any, string, map[string]string) error

func (*ConnFake) Consume

func (*ConnFake) ForceReset

func (c *ConnFake) ForceReset(context.Context)

func (*ConnFake) GetRoutingTable

func (c *ConnFake) GetRoutingTable(_ context.Context, _ map[string]string, _ []string, database, _ string) (*idb.RoutingTable, error)

func (*ConnFake) HasFailed

func (c *ConnFake) HasFailed() bool

func (*ConnFake) IdleDate

func (c *ConnFake) IdleDate() time.Time

func (*ConnFake) IsAlive

func (c *ConnFake) IsAlive() bool

func (*ConnFake) Keys

func (c *ConnFake) Keys(idb.StreamHandle) ([]string, error)

func (*ConnFake) Next

func (*ConnFake) Reset

func (c *ConnFake) Reset(context.Context)

func (*ConnFake) Run

func (c *ConnFake) Run(_ context.Context, _ idb.Command, txConfig idb.TxConfig) (idb.StreamHandle, error)

func (*ConnFake) RunTx

func (*ConnFake) SelectDatabase

func (c *ConnFake) SelectDatabase(database string)

func (*ConnFake) ServerName

func (c *ConnFake) ServerName() string

func (*ConnFake) ServerVersion

func (c *ConnFake) ServerVersion() string

func (*ConnFake) SetBoltLogger

func (c *ConnFake) SetBoltLogger(log.BoltLogger)

func (*ConnFake) TxBegin

func (c *ConnFake) TxBegin(_ context.Context, txConfig idb.TxConfig) (idb.TxHandle, error)

func (*ConnFake) TxCommit

func (c *ConnFake) TxCommit(context.Context, idb.TxHandle) error

func (*ConnFake) TxRollback

func (c *ConnFake) TxRollback(context.Context, idb.TxHandle) error

func (*ConnFake) Version

func (c *ConnFake) Version() db.ProtocolVersion

type Next

type Next struct {
	Record  *db.Record
	Summary *db.Summary
	Err     error
}

type PoolFake

type PoolFake struct {
	BorrowConn  db.Connection
	BorrowErr   error
	ReturnHook  func()
	CleanUpHook func()
	BorrowHook  func() (db.Connection, error)
}

func (*PoolFake) Borrow

func (*PoolFake) CleanUp

func (p *PoolFake) CleanUp(context.Context) error

func (*PoolFake) Return

func (p *PoolFake) Return(context.Context, db.Connection) error

type RecordedTx

type RecordedTx struct {
	Origin    string
	Mode      idb.AccessMode
	Bookmarks []string
	Timeout   time.Duration
	Meta      map[string]any
}

type RouterFake

type RouterFake struct {
	Invalidated            bool
	InvalidatedDb          string
	ReadersRet             []string
	ReadersHook            func(bookmarks func(context.Context) ([]string, error), database string) ([]string, error)
	WritersRet             []string
	WritersHook            func(bookmarks func(context.Context) ([]string, error), database string) ([]string, error)
	Err                    error
	CleanUpHook            func()
	GetNameOfDefaultDbHook func(user string) (string, error)
	InvalidatedServer      string
}

func (*RouterFake) CleanUp

func (r *RouterFake) CleanUp(ctx context.Context) error

func (*RouterFake) GetNameOfDefaultDatabase

func (r *RouterFake) GetNameOfDefaultDatabase(ctx context.Context, bookmarks []string, user string, boltLogger log.BoltLogger) (string, error)

func (*RouterFake) Invalidate

func (r *RouterFake) Invalidate(ctx context.Context, database string) error

func (*RouterFake) InvalidateReader

func (r *RouterFake) InvalidateReader(ctx context.Context, database string, server string) error

func (*RouterFake) InvalidateWriter

func (r *RouterFake) InvalidateWriter(context.Context, string, string) error

func (*RouterFake) Readers

func (r *RouterFake) Readers(ctx context.Context, bookmarksFn func(context.Context) ([]string, error), database string, log log.BoltLogger) ([]string, error)

func (*RouterFake) Writers

func (r *RouterFake) Writers(ctx context.Context, bookmarksFn func(context.Context) ([]string, error), database string, log log.BoltLogger) ([]string, error)

Jump to

Keyboard shortcuts

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