db

package
v3.14.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 6

Documentation

Overview

The base environment for RDB testing

Flags

This package has pre-defined flags of command:

-dsn_mysql - MySQL DSN used to intialize configuration of mysql connection

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDbFacade deprecated

func InitDbFacade(c *check.C) *f.DbFacade

Constructs "*db/facade/DbFacade" object by configuration of flag.

The checker object is used to trigger panic if the database cannot be opened.

If the environment is not ready(flag is empty), this function returns "nil"

Deprecated: Try to use "flag.SkipFactory"(common/testing/flag) instead

func NewDbConfigByDsn

func NewDbConfigByDsn(dsn string) *commonDb.DbConfig

Initializes a configuration of database by DSN.

If DSN is empty string, this function returns nil pointer.

See "NewDbConfigByFlag(int)"

func NewDbConfigByFlag

func NewDbConfigByFlag(dbFlag int) *commonDb.DbConfig

Initializes a configuration of database by test flags(OWL database)

For example: flag.OWL_DB_PORTAL

See godoc of "common/testing/flag"

func ReleaseDbFacade

func ReleaseDbFacade(c *check.C, dbFacade *f.DbFacade)

Releases "*db/facade/DbFacade" object by configuration of flag.

The checker object is used to trigger panic if the database cannot be released.

func SetupByViableDbConfig deprecated

func SetupByViableDbConfig(c *check.C, configFunc ViableDbConfigFunc) bool

This function is used to:

  1. Checks whether or not the property of "mysql" has been supplied
  2. If it does, supply the data of configuration to callback function

Deprecated: Try to use "flag.SkipFactory"(common/testing/flag) instead

Types

type GinkgoDb

type GinkgoDb struct{}

Provides some utility functions to ease the construction of database connection for testing.

func (*GinkgoDb) GetDbConfig deprecated

func (g *GinkgoDb) GetDbConfig() *commonDb.DbConfig

Constructs "*db/facade/DbFacade" object by default configuration object

To support new property of "flag.OWL_DB_PORTAL", this function checks the flag first or use "flag.F_MySql" for compatibility of old flags.

Deprecated: Since it is possible that a test environment needs multiple connections to different databases,

you should use "*GinkgoDb.InitDbFacadeByFlag" to initialize corresponding databases instead.

func (*GinkgoDb) InitDbFacade

func (g *GinkgoDb) InitDbFacade() *f.DbFacade

Constructs "*db/facade/DbFacade" object by configuration of flag.

The checker object is used to trigger panic if the database cannot be opened.

If the environment is not ready(flag is empty), this function returns "nil"

func (*GinkgoDb) InitDbFacadeByDbConfig

func (g *GinkgoDb) InitDbFacadeByDbConfig(dbConfig *commonDb.DbConfig) *f.DbFacade

Constructs "*db/facade/DbFacade" object by configuration object

This function uses "Ginkgo" assertion to ensure that the database connection gets succeeded.

func (*GinkgoDb) InitDbFacadeByFlag

func (g *GinkgoDb) InitDbFacadeByFlag(flag int) *f.DbFacade

Constructs "*db/facade/DbFacade" object by test flags(OWL database)

For example: flag.OWL_DB_PORTAL

See godoc of "common/testing/flag"

func (*GinkgoDb) ReleaseDbFacade

func (g *GinkgoDb) ReleaseDbFacade(dbFacade *f.DbFacade)

Releases "*db/facade/DbFacade" object by configuration of flag.

The checker object is used to trigger panic if the database cannot be released.

type ViableDbConfigFunc

type ViableDbConfigFunc func(config *commonDb.DbConfig)

This callback is used to setup a viable database configuration for testing.

Jump to

Keyboard shortcuts

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