Documentation ¶
Index ¶
- Constants
- func FormatContainerTeardownError(err error) error
- func FormatDockerContainerError(err error) error
- func FormatDockerPoolError(err error) error
- func FormatSqlServerContainerSetupError(err error) error
- func GetMockEndpoints(dsnSlice []database.Dsn) []database.Endpoint
- func GetMockOps() map[string]database.Operation
- func GetRootProjectPath() (string, error)
- func GetTestdataFolderPath() (string, error)
- func GetUnexportedField(field reflect.Value) interface{}
- func RunSqlServerContainer(dockerPool *dockertest.Pool) (database.Dsn, *sql.DB, *dockertest.Resource, error)
- func SetupSingleSqlServerContainer() (database.Dsn, *sql.DB, *dockertest.Resource, error)
- func TeardownContainer(resource *dockertest.Resource) error
Constants ¶
View Source
const ( MockK8sName = "281cb030-9d56-48fa-b433-57237c9e1188" MockOutputUser = "testuser" MockOutputPass = "testpass" MockOutputDbName = "mydbtest281cb030" // DbNamePrefix + the first 8 chars of MockK8sName // Testing stored procedure-specific values DbNamePrefix = "mydbtest" LeftTrimLength = "8" // TODO: Check that stored procedure is idempotent, i.e. it returns the correct username and password depending on // the k8sName, and not always the same CreateSp = `create proc sp_create (@` + opInputK8sName + ` varchar(max), @` + opOutputUser + ` varchar(max) OUTPUT, @` + opOutputPass + ` varchar(max) OUTPUT, @` + opOutputDbName + ` varchar(max) OUTPUT) as declare @sql varchar(max) declare @tempDbName varchar(max) set @tempDbName=CONCAT('` + DbNamePrefix + `', (SELECT LEFT(CONVERT(varchar(255), @k8sName),` + LeftTrimLength + `))) IF COUNT((DB_ID(@tempDbName))) = 0 BEGIN set @sql = CONCAT('create database ',@tempDbName) exec (@sql) END select @username='` + MockOutputUser + `',@password='` + MockOutputPass + `',@dbName='` + MockOutputDbName + `'` DeleteSp = `create proc sp_delete (@` + opInputK8sName + ` varchar(max)) as declare @sql varchar(max) declare @dbname varchar(255) set @dbname=CONCAT('` + DbNamePrefix + `', (SELECT LEFT(CONVERT(varchar(255), @k8sName),8))) IF COUNT((DB_ID(@dbname))) > 0 BEGIN set @sql = CONCAT('drop database ',@dbname) exec (@sql) END` )
View Source
const (
SqlServerDriver = "sqlserver"
)
Variables ¶
This section is empty.
Functions ¶
func FormatDockerPoolError ¶
func GetMockOps ¶
func GetRootProjectPath ¶
GetRootProjectPath is a utility function which gets the root project path based on the location of the main.go file. Do not move main.go in a place other than the root project path.
func GetTestdataFolderPath ¶
func GetUnexportedField ¶
func RunSqlServerContainer ¶
func RunSqlServerContainer(dockerPool *dockertest.Pool) (database.Dsn, *sql.DB, *dockertest.Resource, error)
RunSqlServerContainer creates a new docker container running on dockerPool.
func SetupSingleSqlServerContainer ¶
SetupSingleSqlServerContainer provisions a single sql server container
func TeardownContainer ¶
func TeardownContainer(resource *dockertest.Resource) error
TeardownContainer purges a container and linked volumes from docker.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.