testutils

package
v0.1.0 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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipUnlessAtlasServerRunning = func() func(t *testing.T) {
	return func(t *testing.T) {
		if atlasServerRunning {
			return
		}
		skipUnlessAtlasServerCalled = true
		if atlasServerNotRunning {
			MustSkipf(t, "Atlas server not running at %s", AtlasServerURL())
			return
		}
		client := atlas.NewAuthClient(AtlasServerURL(), user.Credentials{CloudUsername(), CloudAPIKey()})
		if err := client.Status(); err != nil {
			atlasServerNotRunning = true
			MustSkipf(t, "Atlas server not running at %s", AtlasServerURL())
			return
		}
		atlasServerRunning = true
	}
}()

SkipUnlessAtlasServerRunning skips tests if there is no Atlas server running at the configured testing url (see: AtlasServerURL())

View Source
var SkipUnlessExpiredAccessTokenPresent = func() func(t *testing.T) {
	return func(t *testing.T) {
		skipUnlessExpiredAccessTokenCalled = true
		if ExpiredAccessToken() == "" {
			MustSkipf(t, "expired access token not detected in environment")
		}
		return
	}
}()

SkipUnlessExpiredAccessTokenPresent skips tests if there is no expired access token set as an environment URL

View Source
var SkipUnlessRealmServerRunning = func() func(t *testing.T) {
	return func(t *testing.T) {
		if realmServerRunning {
			return
		}
		skipUnlessRealmServerCalled = true
		if realmServerNotRunning {
			MustSkipf(t, "Realm server not running at %s", RealmServerURL())
			return
		}
		client := realm.NewClient(RealmServerURL())
		if err := client.Status(); err != nil {
			realmServerNotRunning = true
			MustSkipf(t, "Realm server not running at %s", RealmServerURL())
			return
		}
		realmServerRunning = true
	}
}()

SkipUnlessRealmServerRunning skips tests if there is no Realm server running at the configured testing url (see: RealmServerURL())

Functions

func AtlasServerURL

func AtlasServerURL() string

AtlasServerURL returns the Atlas server url to use for testing

func CloudAPIKey

func CloudAPIKey() string

CloudAPIKey returns the Cloud api key to use for testing

func CloudAdminAPIKey

func CloudAdminAPIKey() string

CloudAdminAPIKey returns the Cloud admin api key

func CloudAdminUsername

func CloudAdminUsername() string

CloudAdminUsername returns the Cloud admin username

func CloudAtlasClusterCount

func CloudAtlasClusterCount() int

CloudAtlasClusterCount returns the count of clusters to use for testing

func CloudAtlasDataLakeCount

func CloudAtlasDataLakeCount() int

CloudAtlasDataLakeCount returns the count of clusters to use for testing

func CloudGroupID

func CloudGroupID() string

CloudGroupID returns the Cloud group id to use for testing

func CloudGroupName

func CloudGroupName() string

CloudGroupName returns the Cloud group id to use for testing

func CloudUsername

func CloudUsername() string

CloudUsername returns the Cloud username to use for testing

func ExpiredAccessToken

func ExpiredAccessToken() string

ExpiredAccessToken returns an expired access token to use for testing

func MustSkipf

func MustSkipf(t *testing.T, format string, args ...interface{})

MustSkipf skips a test suite, but panics if BAAS_NO_SKIP_TEST is set

func NewTempDir

func NewTempDir(name string) (string, func(), error)

NewTempDir constructs a new temporary directory and returns the directory name along with a cleanup function or any error that occurred during the process

func RealmServerURL

func RealmServerURL() string

RealmServerURL returns the Realm server url to use for testing

func SetupHomeDir

func SetupHomeDir(newHome string) (string, func())

SetupHomeDir sets up the $HOME directory for a test and returns the directory name along with a reset function

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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