testutil

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 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 AddCitusSourceToHasura

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

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 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 StartHasuraWithCitusSource

func StartHasuraWithCitusSource(t TestingT, image string) (string, string, 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