testutil

package
v0.0.0-...-ffce80e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestDir

func CreateTestDir(t *testing.T) string

func FindFreePort

func FindFreePort() int

FindFreePort returns an available port that can be used for a server. If any errors are encountered, this function will panic and fail the current test.

func StartDuckSqlServer

func StartDuckSqlServer(t *testing.T, dir string, persistentSystemVars map[string]string, testEnv *TestEnv) error

StartDuckSqlServer starts a sql-server on a free port from the specified directory |dir|. If |peristentSystemVars| is populated, then those system variables will be set, persistently, for the database, before the sql-server is started.

func StopDuckSqlServer

func StopDuckSqlServer(t *testing.T, duckProcess *os.Process)

StopDuckSqlServer stops the running Dolt sql-server. If any errors are encountered while stopping the Dolt sql-server, this function will fail the current test.

func WaitForSqlServerToStart

func WaitForSqlServerToStart(database *sqlx.DB) error

WaitForSqlServerToStart polls the specified database to wait for it to become available, pausing between retry attempts, and returning an error if it is not able to verify that the database is available.

Types

type TestEnv

type TestEnv struct {
	MySqlContainer                      string
	MySqlPort, DuckPort, DuckPgPort     int
	DuckProcess                         *os.Process
	DuckLogFilePath, OldDuckLogFilePath string
	DuckLogFile, MysqlLogFile           *os.File
	TestDir                             string
	OriginalWorkingDir                  string
	MyDuckServer                        *sqlx.DB
}

Create a struct that stores all these values:

func NewTestEnv

func NewTestEnv() *TestEnv

Jump to

Keyboard shortcuts

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