Documentation ¶
Index ¶
- Constants
- func AsDefaultCredentials(ctx *AssertContext)
- func AsReadOnlyCredentials(ctx *AssertContext)
- func AsStaticCredentials(ctx *AssertContext)
- func AssertLifecycleWorks(gcsCLIPath string, ctx AssertContext)
- func GenerateRandomString(params ...int) string
- func MakeConfigFile(cfg *config.GCSCli) string
- func MakeContentFile(content string) string
- func RunGCSCLI(gcsCLIPath, configPath, subcommand string, args ...string) (*gexec.Session, error)
- type AssertContext
- type AssertContextConfigOption
Constants ¶
const GoogleAppCredentialsEnv = "GOOGLE_APPLICATION_CREDENTIALS"
GoogleAppCredentialsEnv is the environment variable expected to be populated with a path to a Service Account File for testing Application Default Credentials
const NoLongEnv = "SKIP_LONG_TESTS"
NoLongEnv must be set in the environment to enable skipping long running tests
const NoLongMsg = "environment variable %s filled, skipping long test"
NoLongMsg is the template used when BucketNoLongEnv's environment variable has not been populated.
const ServiceAccountFileEnv = "GOOGLE_SERVICE_ACCOUNT"
ServiceAccountFileEnv is the environment variable expected to be populated with a Service Account File for testing
const ServiceAccountFileMsg = "environment variable %s expected to contain a valid Service Account File but was empty"
ServiceAccountFileMsg is the template used when ServiceAccountFileEnv has not been populated
Variables ¶
This section is empty.
Functions ¶
func AsDefaultCredentials ¶
func AsDefaultCredentials(ctx *AssertContext)
AsDefaultCredentials configures the AssertContext to authenticate using Application Default Credentials populated using the testing service account file.
func AsReadOnlyCredentials ¶
func AsReadOnlyCredentials(ctx *AssertContext)
AsReadOnlyCredentials configures the AssertContext to be used soley for public, read-only operations.
func AsStaticCredentials ¶
func AsStaticCredentials(ctx *AssertContext)
AsStaticCredentials configures the AssertContext to authenticate explicitly using a Service Account File
func AssertLifecycleWorks ¶
func AssertLifecycleWorks(gcsCLIPath string, ctx AssertContext)
AssertLifecycleWorks tests the main blobstore object lifecycle from creation to deletion.
This is using gomega matchers, so it will fail if called outside an 'It' test.
func GenerateRandomString ¶
GenerateRandomString generates a random string of desired length (default: 25)
func MakeConfigFile ¶
MakeConfigFile creates a config file from a GCSCli config struct
func MakeContentFile ¶
MakeContentFile creates a temporary file with content to upload to GCS
Types ¶
type AssertContext ¶
type AssertContext struct { // Config is the configuration used to Config *config.GCSCli // ConfigPath is the path to the file containing the // serialized content of Config. ConfigPath string // GCSFileName is the name of whatever blob is generated in an // assertion. It is the assert's responsibility to remove the blob. GCSFileName string // ExpectedString is the generated content used in an assertion. ExpectedString string // ContentFile is the path of the file containing ExpectedString ContentFile string // contains filtered or unexported fields }
AssertContext contains the generated content to be used within tests.
This allows Assertions to not have to worry about setup and teardown.
func NewAssertContext ¶
func NewAssertContext(options ...AssertContextConfigOption) AssertContext
NewAssertContext returns an AssertContext with all fields which can be generated filled in.
func (*AssertContext) AddConfig ¶
func (ctx *AssertContext) AddConfig(config *config.GCSCli)
AddConfig includes the config.GCSCli required for AssertContext
Configuration is typically not available immediately before a test can be run, hence the need to add it later.
func (*AssertContext) Cleanup ¶
func (ctx *AssertContext) Cleanup()
Cleanup removes artifacts generated by the AssertContext.
func (*AssertContext) Clone ¶
func (ctx *AssertContext) Clone(options ...AssertContextConfigOption) AssertContext
Clone returns a new AssertContext configured using the provided options. This overwrites the previous options of the context.
This is useful in assertions where initial setup must be done under one form of authentication and the actual assertion is done under another.
Note: The returned AssertContext is a distinct AssertContext, Cleanup must be called to remove testing files from the filesystem.
type AssertContextConfigOption ¶
type AssertContextConfigOption func(ctx *AssertContext)
AssertContextConfigOption is an option used for configuring an AssertContext's handling of the config.
The behavior for an AssertContextAuthOption is applied when config is added