testutil

package
v0.0.0-...-0907076 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugCommandPrefix        = "\nCMD>"
	DebugCommandPrefixWithDir = "\nCMD %s>"
	DebugOutPrefix            = "OUT: "
	DebugErrPrefix            = "ERR: "
)

Variables

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

	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 AddPGSourceToHasura

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

func CloseWithLogOnErr

func CloseWithLogOnErr(closer io.Closer)

func Hasura

func Hasura(opts CmdOpts) *Session

func NewHttpcClient

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

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, error)

func StartHasura

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