tests

package
v0.0.0-...-269d6e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSimpleTx

func NewSimpleTx(ds datastore.Datastore) dse.TxnExt

NewSimpleTx creates a transaction.

func PostgresURL

func PostgresURL() (string, error)

PostgresURL gets a Postgres database URL for test. It always creates a new database on the server so tests won't clash with each other. It connects to the server specified by PG_URL envvar if present, or starts a new Postgres docker container which stops automatically after 10 minutes.

Types

type SimpleTx

type SimpleTx struct {
	// contains filtered or unexported fields
}

SimpleTx implements the transaction interface for datastores who do not have any sort of underlying transactional support.

func (*SimpleTx) Commit

func (bt *SimpleTx) Commit(ctx context.Context) error

Commit confirms changes done in the transaction.

func (*SimpleTx) Delete

func (bt *SimpleTx) Delete(_ context.Context, key datastore.Key) error

Delete deletes a key.

func (*SimpleTx) Discard

func (bt *SimpleTx) Discard(_ context.Context)

Discard cancels the changes done in the transaction.

func (*SimpleTx) Get

func (bt *SimpleTx) Get(ctx context.Context, k datastore.Key) ([]byte, error)

Get returns a key value within the transaction.

func (*SimpleTx) GetSize

func (bt *SimpleTx) GetSize(ctx context.Context, k datastore.Key) (int, error)

GetSize returns the size of the key value.

func (*SimpleTx) Has

func (bt *SimpleTx) Has(ctx context.Context, k datastore.Key) (bool, error)

Has returns true if the key exist, false otherwise.

func (*SimpleTx) Put

func (bt *SimpleTx) Put(_ context.Context, key datastore.Key, val []byte) error

Put sets the value for a key.

func (*SimpleTx) Query

func (bt *SimpleTx) Query(ctx context.Context, q query.Query) (query.Results, error)

Query executes a query within the transaction scope.

func (*SimpleTx) QueryExtended

func (bt *SimpleTx) QueryExtended(q dse.QueryExt) (query.Results, error)

QueryExtended executes an extended query within the transaction scope.

type TxMapDatastore

type TxMapDatastore struct {
	*datastore.MapDatastore
	// contains filtered or unexported fields
}

TxMapDatastore is a in-memory datastore that satisfies TxnDatastore.

func NewTxMapDatastore

func NewTxMapDatastore() *TxMapDatastore

NewTxMapDatastore returns a new TxMapDatastore.

func (*TxMapDatastore) Clone

func (d *TxMapDatastore) Clone() (*TxMapDatastore, error)

Clone returns a cloned datastore.

func (*TxMapDatastore) Delete

func (d *TxMapDatastore) Delete(ctx context.Context, key datastore.Key) error

Delete deletes a key.

func (*TxMapDatastore) Get

func (d *TxMapDatastore) Get(ctx context.Context, key datastore.Key) ([]byte, error)

Get returns the value for a key.

func (*TxMapDatastore) NewTransaction

func (d *TxMapDatastore) NewTransaction(readOnly bool) (datastore.Txn, error)

NewTransaction creates a transaction. A read-only transaction should be indicated with readOnly equal true.

func (*TxMapDatastore) NewTransactionExtended

func (d *TxMapDatastore) NewTransactionExtended(readOnly bool) (dse.TxnExt, error)

NewTransactionExtended creates an extended transaction. A read-only transaction should be indicated with readOnly equal true.

func (*TxMapDatastore) Put

func (d *TxMapDatastore) Put(ctx context.Context, key datastore.Key, data []byte) error

Put sets the value of a key.

func (*TxMapDatastore) Query

Query executes a query in the datastore.

func (*TxMapDatastore) QueryExtended

func (d *TxMapDatastore) QueryExtended(q dse.QueryExt) (query.Results, error)

QueryExtended executes an extended query.

Jump to

Keyboard shortcuts

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