testutil

package
v2.39.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugCommandPrefix        = "\nCMD>"
	DebugCommandPrefixWithDir = "\nCMD %s>"
	DebugOutPrefix            = "OUT: "
	DebugErrPrefix            = "ERR: "
	DefaultE2ETestTimeout     = 60 // in seconds
)

Variables

View Source
var (
	HasuraDockerImage = func() string {
		graphqlEngineDockerImage := os.Getenv("HASURA_TEST_CLI_HGE_DOCKER_IMAGE")
		if graphqlEngineDockerImage != "" {
			return graphqlEngineDockerImage
		}
		return ""
	}()

	TestAdminSecret = os.Getenv("HASURA_GRAPHQL_TEST_ADMIN_SECRET")

	DockerSwitchIP = func() string {
		switch runtime.GOOS {
		case "darwin", "windows":
			return "host.docker.internal"
		}
		return "172.17.0.1"
	}()
	Hostname      = "localhost"
	BaseURL       = fmt.Sprintf("http://%s", Hostname)
	MSSQLPassword = "MSSQLp@ssw0rd"
	CLIBinaryPath = func() string {
		if os.Getenv("CI") == "true" {
			return "/build/_cli_output/binaries/cli-hasura-linux-amd64"
		}

		hasuraCliPathEnv := os.Getenv("HASURA_TEST_CLI_PATH")
		if hasuraCliPathEnv != "" {
			return hasuraCliPathEnv
		}

		return "hasura"
	}()
)

this can be overridden by ldflags

Functions

func AddBigQuerySourceToHasura added in v2.20.0

func AddBigQuerySourceToHasura(t TestingT, globalSelectLimit int, sourceName, serviceAccount, projectId, dataset, hasuraEndpoint string)

func AddCitusSourceToHasura

func AddCitusSourceToHasura(t TestingT, hasuraEndpoint, connectionString, sourceName string)

func AddCockroachSourceToHasura added in v2.18.0

func AddCockroachSourceToHasura(t TestingT, hasuraEndpoint, connectionString, sourceName string)

func AddDatabaseToHasura added in v2.14.0

func AddDatabaseToHasura(t TestingT, hgeEndpoint, sourceName, databaseKind string) (string, func())

func AddMSSQLSourceToHasura

func AddMSSQLSourceToHasura(t TestingT, hasuraEndpoint, connectionString, sourceName string)

func AddPGSourceToHasura

func AddPGSourceToHasura(t TestingT, hasuraEndpoint, connectionString, sourceName string)

func CloseWithLogOnErr

func CloseWithLogOnErr(closer io.Closer)

func Command

func Command(cmdPath string, opts CmdOpts) *Session

to run commands other than hasura

func Hasura

func Hasura(opts CmdOpts) *Session

func NewHttpcClient

func NewHttpcClient(t *testing.T, port string, headers map[string]string) *httpc.Client

func NewRequest

func NewRequest(t *testing.T, method, urlStr string, body interface{}) *http.Request

func RandDirName

func RandDirName() string

func RemoveDir

func RemoveDir(dirName string)

func RemoveHasuraConfigHomeDirectory

func RemoveHasuraConfigHomeDirectory()

func RunCommandAndSucceed

func RunCommandAndSucceed(opts CmdOpts) *Session

func SendHTTPRequestWithFileAsBody

func SendHTTPRequestWithFileAsBody(t *testing.T, filepath, url string) *http.Response

func StartCitusContainer

func StartCitusContainer(t TestingT) (string, func())

StartCitusContainer and creates a database and returns the port number

func StartCockroachContainer added in v2.18.0

func StartCockroachContainer(t TestingT) (connectionString string, teardown func())

func StartHasura

func StartHasura(t TestingT, image string) (port string, teardown func())

func StartHasuraCLIMigrations

func StartHasuraCLIMigrations(t TestingT, image string, pgConnectionUrl string, metadataDir, migrationsDir string) (port string, teardown func())

func StartHasuraWithBigQuerySource added in v2.20.0

func StartHasuraWithBigQuerySource(t TestingT, image string) (hasuraPort, sourceName, projectId, dataset string, teardown func())

func StartHasuraWithCitusSource

func StartHasuraWithCitusSource(t TestingT, image string) (string, string, func())

func StartHasuraWithCockroachSource added in v2.18.0

func StartHasuraWithCockroachSource(t TestingT, image string) (hasuraPort, sourceName string, teardown func())

func StartHasuraWithMSSQLSource

func StartHasuraWithMSSQLSource(t *testing.T, version string) (string, string, func())

starts a hasura instance with a metadata database and a msssql source returns the mssql port, source name and teardown function

func StartHasuraWithMetadataDatabase

func StartHasuraWithMetadataDatabase(t TestingT, image string) (port string, teardown func())

func StartHasuraWithPG

func StartHasuraWithPG(t TestingT, image string, pgConnectionUrl string, dockerOpts ...func(*docker.HostConfig)) (port string, teardown func())

func StartMSSQLContainer

func StartMSSQLContainer(t TestingT) (string, func())

startsMSSQLContainer and creates a database and returns the port number

func StartPGContainer

func StartPGContainer(t TestingT) (connectionString string, teardown func())

Types

type CmdOpts

type CmdOpts struct {
	Args             []string
	WorkingDirectory string
}

type TestingT

type TestingT interface {
	Skip(args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

TestingT is a workaround for using test helpers on Ginkgo tests and normal go tests this interfaces is introduced ginkgo specs do not have a handle of *testing.T and therefore cannot be used directly in test helpers

Jump to

Keyboard shortcuts

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