testcommon

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEndpointSuffix       = "core.windows.net/"
	DefaultBlobEndpointSuffix   = "blob.core.windows.net/"
	AccountNameEnvVar           = "AZURE_STORAGE_ACCOUNT_NAME"
	AccountKeyEnvVar            = "AZURE_STORAGE_ACCOUNT_KEY"
	DefaultEndpointSuffixEnvVar = "AZURE_STORAGE_ENDPOINT_SUFFIX"
	SubscriptionID              = "SUBSCRIPTION_ID"
	ResourceGroupName           = "RESOURCE_GROUP_NAME"
)
View Source
const (
	FakeStorageAccount = "fakestorage"
	FakeBlobStorageURL = "https://fakestorage.blob.core.windows.net"
	FakeDFSStorageURL  = "https://fakestorage.dfs.core.windows.net"
	FakeToken          = "faketoken"
)
View Source
const (
	FileSystemPrefix            = "gofs"
	FilePrefix                  = "gotestfile"
	DirPrefix                   = "gotestdir"
	DefaultData                 = "Godatalakedata"
	InvalidHeaderErrorSubstring = "invalid header field" // error thrown by the http client
)

Variables

View Source
var (
	DatalakeContentType        = "my_type"
	DatalakeContentDisposition = "my_disposition"
	DatalakeCacheControl       = "control"
	DatalakeContentLanguage    = "my_language"
	DatalakeContentEncoding    = "my_encoding"
)
View Source
var BasicHeaders = file.HTTPHeaders{
	ContentType:        &DatalakeContentType,
	ContentDisposition: &DatalakeContentDisposition,
	CacheControl:       &DatalakeCacheControl,
	ContentMD5:         nil,
	ContentLanguage:    &DatalakeContentLanguage,
	ContentEncoding:    &DatalakeContentEncoding,
}
View Source
var BasicMetadata = map[string]*string{"Foo": to.Ptr("bar")}

Functions

func AfterTest

func AfterTest(t *testing.T, suite string, test string)

func BeforeTest

func BeforeTest(t *testing.T, suite string, test string)

func CreateNewDir

func CreateNewDir(ctx context.Context, _require *require.Assertions, dirName string, filesystemClient *filesystem.Client) *directory.Client

func CreateNewFile

func CreateNewFile(ctx context.Context, _require *require.Assertions, fileName string, filesystemClient *filesystem.Client) *file.Client

func CreateNewFileSystem

func CreateNewFileSystem(ctx context.Context, _require *require.Assertions, filesystemName string, serviceClient *service.Client) *filesystem.Client

func DeleteDir

func DeleteDir(ctx context.Context, _require *require.Assertions, dirClient *directory.Client)

func DeleteFile

func DeleteFile(ctx context.Context, _require *require.Assertions, fileClient *file.Client)

func DeleteFileSystem

func DeleteFileSystem(ctx context.Context, _require *require.Assertions, filesystemClient *filesystem.Client)

func GenerateData

func GenerateData(sizeInBytes int) (io.ReadSeekCloser, []byte)

func GenerateDirName

func GenerateDirName(testName string) string

func GenerateEntityName

func GenerateEntityName(testName string) string

func GenerateFileName

func GenerateFileName(testName string) string

func GenerateFileSystemName

func GenerateFileSystemName(testName string) string

func GetDirClient

func GetDirClient(fsName, dirName string, t *testing.T, accountType TestAccountType, options *directory.ClientOptions) (*directory.Client, error)

func GetFileClient

func GetFileClient(fsName, fName string, t *testing.T, accountType TestAccountType, options *file.ClientOptions) (*file.Client, error)

func GetFileSystemClient

func GetFileSystemClient(fsName string, t *testing.T, accountType TestAccountType, options *filesystem.ClientOptions) (*filesystem.Client, error)

func GetGenericAccountInfo

func GetGenericAccountInfo(accountType TestAccountType) (string, string)

func GetGenericConnectionString

func GetGenericConnectionString(accountType TestAccountType) (*string, error)

func GetGenericSharedKeyCredential

func GetGenericSharedKeyCredential(accountType TestAccountType) (*azdatalake.SharedKeyCredential, error)

func GetRelativeTimeFromAnchor

func GetRelativeTimeFromAnchor(anchorTime *time.Time, amount time.Duration) time.Time

func GetRequiredEnv

func GetRequiredEnv(name string) (string, error)

GetRequiredEnv gets an environment variable by name and returns an error if it is not found

func GetServiceClient

func GetServiceClient(t *testing.T, accountType TestAccountType, options *service.ClientOptions) (*service.Client, error)

func GetServiceClientFromConnectionString

func GetServiceClientFromConnectionString(t *testing.T, accountType TestAccountType, options *service.ClientOptions) (*service.Client, error)

func GetServiceClientNoCredential

func GetServiceClientNoCredential(t *testing.T, sasUrl string, options *service.ClientOptions) (*service.Client, error)

func ServiceGetFileSystemClient

func ServiceGetFileSystemClient(filesystemName string, s *service.Client) *filesystem.Client

func SetClientOptions

func SetClientOptions(t *testing.T, opts *azcore.ClientOptions)

func ValidateErrorCode

func ValidateErrorCode(_require *require.Assertions, err error, code datalakeerror.StorageErrorCode)

Types

type TestAccountType

type TestAccountType string
const (
	TestAccountDefault    TestAccountType = ""
	TestAccountSecondary  TestAccountType = "SECONDARY_"
	TestAccountPremium    TestAccountType = "PREMIUM_"
	TestAccountSoftDelete TestAccountType = "SOFT_DELETE_"
	TestAccountDatalake   TestAccountType = "DATALAKE_"
	TestAccountImmutable  TestAccountType = "IMMUTABLE_"
)

Jump to

Keyboard shortcuts

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