Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDB(dbType string, opts ...Option) (string, error)
- func MustCreateDB(t *testing.T, dbType string, opts ...Option) string
- func MustCreatePostgresDB(t *testing.T, opts ...Option) string
- func MustCreateRedisDB(t *testing.T, opts ...Option) string
- func RemoveDB(dbType, uri string) error
- type CreateDBRequest
- type CreateDBResponse
- type ErrorMessage
- type Option
- type RemoveDBRequest
- type Request
- type Response
Constants ¶
const ( // DatabasePostgres is a postgres database DatabasePostgres = "postgres" // DatabaseRedis is a redis database DatabaseRedis = "redis" )
Database types
Variables ¶
var ( // ErrInvalidDatabaseType is returned when an invalid database type is passed ErrInvalidDatabaseType = errors.New("invalid database type") )
Functions ¶
func CreateDB ¶
CreateDB create a database and return connection string it up to the caller to remove the database by calling RemoveDB
func MustCreateDB ¶
MustCreateDB create a database and return connection string or fail the test it will also remove the database after the test is finished
func MustCreatePostgresDB ¶
MustCreatePostgresDB create a postgres database and return connection string or fail the test
func MustCreateRedisDB ¶
MustCreateRedisDB create a redis database and return connection string or fail the test
Types ¶
type CreateDBRequest ¶
type CreateDBRequest struct { Type string `json:"type"` Migrations string `json:"migrations"` Fixtures string `json:"fixtures"` // postgres instance information InstancePort uint32 `json:"instance_port"` InstanceUser string `json:"instance_user"` InstancePass string `json:"instance_pass"` InstanceName string `json:"instance_name"` }
CreateDBRequest is the request object for creating a database
type CreateDBResponse ¶
type CreateDBResponse struct {
URI string `json:"uri"`
}
CreateDBResponse is the response object for creating a database
type ErrorMessage ¶
type ErrorMessage struct {
Error string `json:"error"`
}
ErrorMessage is representing rest api error object
type Option ¶
type Option func(*config) error
Option is a function that configures the client.
func WithDefaultMigrations ¶
func WithDefaultMigrations() Option
WithDefaultMigrations configures the client to use the default migrations.
func WithFixtures ¶
WithFixtures configures the client to use the given fixtures.
func WithInstance ¶
WithInstance configures the client to use the given postgres instance.
func WithMigrations ¶
WithMigrations configures the client to use the given migrations.
type RemoveDBRequest ¶
RemoveDBRequest is the request object for removing a database
type Request ¶
type Request interface { CreateDBRequest | RemoveDBRequest }
Request is eatheir CreateDBRequest or RemoveDBRequest
type Response ¶
type Response interface { CreateDBResponse | interface{} }
Response is eatheir CreateDBResponse or ErrorMessage