Documentation ¶
Index ¶
- Variables
- func GenerateValidAccessToken() string
- func MustSkipf(t *testing.T, format string, args ...interface{})
- func NewEmptyStorage() *storage.Storage
- func NewPopulatedDeprecatedStorage(username, apiKey string) *storage.Storage
- func NewPopulatedStorage(privateAPIKey, refreshToken, accessToken string) *storage.Storage
- func So(t *testing.T, actual interface{}, assert Assertion, expected ...interface{})
- type Assertion
- type MemoryStrategy
- type MockClient
- type MockMDBClient
- type MockStitchClient
- func (msc *MockStitchClient) AddSecret(groupID, appID string, secret secrets.Secret) error
- func (msc *MockStitchClient) Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
- func (msc *MockStitchClient) CopyAsset(groupID, appID, fromPath, toPath string) error
- func (msc *MockStitchClient) CreateDraft(groupID, appID string) (*models.AppDraft, error)
- func (msc *MockStitchClient) CreateEmptyApp(groupID, appName, locationName, deploymentModelName string) (*models.App, error)
- func (msc *MockStitchClient) DeleteAsset(groupID, appID, path string) error
- func (msc *MockStitchClient) DeployDraft(groupID, appID, draftID string) (*models.Deployment, error)
- func (msc *MockStitchClient) Diff(groupID, appID string, appData []byte, strategy string) ([]string, error)
- func (msc *MockStitchClient) DiscardDraft(groupID, appID, draftID string) error
- func (msc *MockStitchClient) DraftDiff(groupID, appID, draftID string) (*models.DraftDiff, error)
- func (msc *MockStitchClient) Export(groupID, appID string, strategy api.ExportStrategy) (string, io.ReadCloser, error)
- func (msc *MockStitchClient) ExportDependencies(groupID, appID string) (string, io.ReadCloser, error)
- func (msc *MockStitchClient) FetchAppByClientAppID(clientAppID string) (*models.App, error)
- func (msc *MockStitchClient) FetchAppByGroupIDAndClientAppID(groupID, clientAppID string) (*models.App, error)
- func (msc *MockStitchClient) FetchAppsByGroupID(groupID string) ([]*models.App, error)
- func (msc *MockStitchClient) GetDeployment(groupID, appID, deploymentID string) (*models.Deployment, error)
- func (msc *MockStitchClient) GetDrafts(groupID, appID string) ([]models.AppDraft, error)
- func (msc *MockStitchClient) Import(groupID, appID string, appData []byte, strategy string) error
- func (msc *MockStitchClient) InvalidateCache(groupID, appID, path string) error
- func (msc *MockStitchClient) ListAssetsForAppID(groupID, appID string) ([]hosting.AssetMetadata, error)
- func (msc *MockStitchClient) ListSecrets(groupID, appID string) ([]secrets.Secret, error)
- func (msc *MockStitchClient) MoveAsset(groupID, appID, fromPath, toPath string) error
- func (msc *MockStitchClient) RemoveSecretByID(groupID, appID, secretID string) error
- func (msc *MockStitchClient) RemoveSecretByName(groupID, appID, secretName string) error
- func (msc *MockStitchClient) SetAssetAttributes(groupID, appID, path string, attributes ...hosting.AssetAttribute) error
- func (msc *MockStitchClient) UpdateSecretByID(groupID, appID, secretID, secretValue string) error
- func (msc *MockStitchClient) UpdateSecretByName(groupID, appID, secretName, secretValue string) error
- func (msc *MockStitchClient) UploadAsset(groupID, appID, path, hash string, size int64, body io.Reader, ...) error
- func (msc *MockStitchClient) UploadDependencies(groupID, appID, fullPath string) error
- type MongoDBCloudEnv
- type RequestData
- type ResponseBody
Constants ¶
This section is empty.
Variables ¶
var SkipUnlessMongoDBCloudRunning = func() func(t *testing.T) { return func(t *testing.T) { cloudEnv := ENV() if mongoDBCloudNotRunning { MustSkipf(t, "MongoDB Cloud not running at %s", cloudEnv.CloudAPIBaseURL) return } req, err := http.NewRequest(http.MethodGet, cloudEnv.CloudAPIBaseURL, nil) if err != nil { panic(err) } resp, err := http.DefaultClient.Do(req) if err != nil || resp.StatusCode != http.StatusOK { MustSkipf(t, "MongoDB Cloud not running at %s", cloudEnv.CloudAPIBaseURL) return } } }()
SkipUnlessMongoDBCloudRunning skips tests if there is no cloud instance running at the chosen base URL
Functions ¶
func GenerateValidAccessToken ¶
func GenerateValidAccessToken() string
GenerateValidAccessToken generates and returns a valid access token *from the future*
func MustSkipf ¶
MustSkipf skips a test suite, but panics if STITCH_NO_SKIP_TEST is set, indicating that skipping is not permitted.
func NewEmptyStorage ¶
NewEmptyStorage creates a new empty MemoryStrategy
func NewPopulatedDeprecatedStorage ¶ added in v1.3.0
NewPopulatedDeprecatedStorage creates a new MemoryStrategy populated with data in the old deprecated format
func NewPopulatedStorage ¶
NewPopulatedStorage creates a new MemoryStrategy populated with data
Types ¶
type Assertion ¶
type Assertion func(actual interface{}, expected ...interface{}) string
Assertion is a func that checks some condition for use in a test
type MemoryStrategy ¶
type MemoryStrategy struct {
// contains filtered or unexported fields
}
MemoryStrategy is a storage.Strategy that stores data in memory
func NewMemoryStrategy ¶
func NewMemoryStrategy(data []byte) *MemoryStrategy
NewMemoryStrategy returns a new MemoryStrategy
func (*MemoryStrategy) Read ¶
func (ms *MemoryStrategy) Read() ([]byte, error)
Read reads the data currently stored in memory storage
func (*MemoryStrategy) Write ¶
func (ms *MemoryStrategy) Write(data []byte) error
Write records the provided data to memory storage
type MockClient ¶
type MockClient struct { RequestData []RequestData Responses []*http.Response // contains filtered or unexported fields }
A MockClient is a new api.Client that can be used to mock out HTTP requests and return responses
func NewMockClient ¶
func NewMockClient(responses []*http.Response) *MockClient
NewMockClient returns a new MockClient
func (*MockClient) ExecuteRequest ¶
func (mc *MockClient) ExecuteRequest(method, path string, options api.RequestOptions) (*http.Response, error)
ExecuteRequest satisfies the api.Client interface, records request data, and returns the provided responses in order
type MockMDBClient ¶
type MockMDBClient struct { WithAuthFn func(username, apiKey string) mdbcloud.Client GroupsFn func() ([]mdbcloud.Group, error) GroupByNameFn func(string) (*mdbcloud.Group, error) DeleteDatabaseUserFn func(groupId, username string) error }
MockMDBClient satisfies a mdbcloud.Client
func (*MockMDBClient) DeleteDatabaseUser ¶
func (mmc *MockMDBClient) DeleteDatabaseUser(groupID, username string) error
DeleteDatabaseUser does nothing
func (*MockMDBClient) GroupByName ¶
func (mmc *MockMDBClient) GroupByName(groupName string) (*mdbcloud.Group, error)
GroupByName will look up the Group given a name
type MockStitchClient ¶
type MockStitchClient struct { CreateEmptyAppFn func(groupID, appName, locationName, deploymentModelName string) (*models.App, error) FetchAppByGroupIDAndClientAppIDFn func(groupID, clientAppID string) (*models.App, error) FetchAppByClientAppIDFn func(clientAppID string) (*models.App, error) FetchAppsByGroupIDFn func(groupID string) ([]*models.App, error) ListAssetsForAppIDFn func(groupID, appID string) ([]string, []hosting.AssetDescription, error) UploadAssetFn func(groupID, appID, path, hash string, size int64, body io.Reader, attributes ...hosting.AssetAttribute) error CopyAssetFn func(groupID, appID, fromPath, toPath string) error MoveAssetFn func(groupID, appID, fromPath, toPath string) error DeleteAssetFn func(groupID, appID, path string) error SetAssetAttributesFn func(groupID, appID, path string, attributes ...hosting.AssetAttribute) error ExportFn func(groupID, appID string, strategy api.ExportStrategy) (string, io.ReadCloser, error) ExportDependencyFn func(groupID, appID string) (string, io.ReadCloser, error) ExportFnCalls [][]string ImportFn func(groupID, appID string, appData []byte, strategy string) error ImportFnCalls [][]string DiffFn func(groupID, appID string, appData []byte, strategy string) ([]string, error) InvalidateCacheFn func(groupID, appID, path string) error ListSecretsFn func(groupID, appID string) ([]secrets.Secret, error) AddSecretFn func(groupID, appID string, secret secrets.Secret) error UpdateSecretByIDFn func(groupID, appID, secretID, secretValue string) error UpdateSecretByNameFn func(groupID, appID, secretName, secretValue string) error RemoveSecretByIDFn func(groupID, appID, secretID string) error RemoveSecretByNameFn func(groupID, appID, secretName string) error UploadDependenciesFn func(groupID, appID, fullPath string) error }
MockStitchClient satisfies an api.StitchClient
func (*MockStitchClient) AddSecret ¶ added in v1.5.0
func (msc *MockStitchClient) AddSecret(groupID, appID string, secret secrets.Secret) error
AddSecret adds a secret to the app
func (*MockStitchClient) Authenticate ¶
func (msc *MockStitchClient) Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
Authenticate will authenticate a user given an auth.AuthenticationProvider
func (*MockStitchClient) CopyAsset ¶ added in v1.2.0
func (msc *MockStitchClient) CopyAsset(groupID, appID, fromPath, toPath string) error
CopyAsset copies an asset
func (*MockStitchClient) CreateDraft ¶ added in v1.6.0
func (msc *MockStitchClient) CreateDraft(groupID, appID string) (*models.AppDraft, error)
CreateDraft returns a mock AppDraft
func (*MockStitchClient) CreateEmptyApp ¶
func (msc *MockStitchClient) CreateEmptyApp(groupID, appName, locationName, deploymentModelName string) (*models.App, error)
CreateEmptyApp does nothing
func (*MockStitchClient) DeleteAsset ¶ added in v1.2.0
func (msc *MockStitchClient) DeleteAsset(groupID, appID, path string) error
DeleteAsset deletes an asset
func (*MockStitchClient) DeployDraft ¶ added in v1.6.0
func (msc *MockStitchClient) DeployDraft(groupID, appID, draftID string) (*models.Deployment, error)
DeployDraft returns a mock Deployment
func (*MockStitchClient) Diff ¶
func (msc *MockStitchClient) Diff(groupID, appID string, appData []byte, strategy string) ([]string, error)
Diff will execute a dry-run of an import, returning a diff of proposed changes
func (*MockStitchClient) DiscardDraft ¶ added in v1.6.0
func (msc *MockStitchClient) DiscardDraft(groupID, appID, draftID string) error
DiscardDraft does nothing
func (*MockStitchClient) DraftDiff ¶ added in v1.6.0
func (msc *MockStitchClient) DraftDiff(groupID, appID, draftID string) (*models.DraftDiff, error)
DraftDiff returns an empty DraftDiff
func (*MockStitchClient) Export ¶
func (msc *MockStitchClient) Export(groupID, appID string, strategy api.ExportStrategy) (string, io.ReadCloser, error)
Export will download a Stitch app as a .zip
func (*MockStitchClient) ExportDependencies ¶ added in v1.12.0
func (msc *MockStitchClient) ExportDependencies(groupID, appID string) (string, io.ReadCloser, error)
Export will download a Stitch app's dependencies
func (*MockStitchClient) FetchAppByClientAppID ¶
func (msc *MockStitchClient) FetchAppByClientAppID(clientAppID string) (*models.App, error)
FetchAppByClientAppID fetches a Stitch app given a clientAppID
func (*MockStitchClient) FetchAppByGroupIDAndClientAppID ¶ added in v1.1.0
func (msc *MockStitchClient) FetchAppByGroupIDAndClientAppID(groupID, clientAppID string) (*models.App, error)
FetchAppByGroupIDAndClientAppID fetches a Stitch app given a groupID and clientAppID
func (*MockStitchClient) FetchAppsByGroupID ¶
func (msc *MockStitchClient) FetchAppsByGroupID(groupID string) ([]*models.App, error)
FetchAppsByGroupID does nothing
func (*MockStitchClient) GetDeployment ¶ added in v1.6.0
func (msc *MockStitchClient) GetDeployment(groupID, appID, deploymentID string) (*models.Deployment, error)
GetDeployment returns a mock Deployment
func (*MockStitchClient) GetDrafts ¶ added in v1.6.0
func (msc *MockStitchClient) GetDrafts(groupID, appID string) ([]models.AppDraft, error)
GetDrafts returns an empty list of AppDrafts
func (*MockStitchClient) Import ¶
func (msc *MockStitchClient) Import(groupID, appID string, appData []byte, strategy string) error
Import will push a local Stitch app to the server
func (*MockStitchClient) InvalidateCache ¶ added in v1.2.0
func (msc *MockStitchClient) InvalidateCache(groupID, appID, path string) error
InvalidateCache requests cache invalidation for the asset at the argued path
func (*MockStitchClient) ListAssetsForAppID ¶ added in v1.2.0
func (msc *MockStitchClient) ListAssetsForAppID(groupID, appID string) ([]hosting.AssetMetadata, error)
ListAssetsForAppID fetches a Stitch app given a clientAppID
func (*MockStitchClient) ListSecrets ¶ added in v1.5.0
func (msc *MockStitchClient) ListSecrets(groupID, appID string) ([]secrets.Secret, error)
ListSecrets lists the secrets of an app
func (*MockStitchClient) MoveAsset ¶ added in v1.2.0
func (msc *MockStitchClient) MoveAsset(groupID, appID, fromPath, toPath string) error
MoveAsset moves an asset
func (*MockStitchClient) RemoveSecretByID ¶ added in v1.5.0
func (msc *MockStitchClient) RemoveSecretByID(groupID, appID, secretID string) error
RemoveSecretByID removes a secret from the app
func (*MockStitchClient) RemoveSecretByName ¶ added in v1.5.0
func (msc *MockStitchClient) RemoveSecretByName(groupID, appID, secretName string) error
RemoveSecretByName removes a secret from the app
func (*MockStitchClient) SetAssetAttributes ¶ added in v1.2.0
func (msc *MockStitchClient) SetAssetAttributes(groupID, appID, path string, attributes ...hosting.AssetAttribute) error
SetAssetAttributes sets an asset's attributes
func (*MockStitchClient) UpdateSecretByID ¶ added in v1.5.0
func (msc *MockStitchClient) UpdateSecretByID(groupID, appID, secretID, secretValue string) error
UpdateSecretByID updates a secret from the app
func (*MockStitchClient) UpdateSecretByName ¶ added in v1.5.0
func (msc *MockStitchClient) UpdateSecretByName(groupID, appID, secretName, secretValue string) error
UpdateSecretByName updates a secret from the app
func (*MockStitchClient) UploadAsset ¶ added in v1.2.0
func (msc *MockStitchClient) UploadAsset(groupID, appID, path, hash string, size int64, body io.Reader, attributes ...hosting.AssetAttribute) error
UploadAsset uploads an asset
func (*MockStitchClient) UploadDependencies ¶ added in v1.8.0
func (msc *MockStitchClient) UploadDependencies(groupID, appID, fullPath string) error
type MongoDBCloudEnv ¶
type MongoDBCloudEnv struct { CloudAPIBaseURL string StitchServerBaseURL string APIKey string Username string AdminUsername string AdminAPIKey string GroupID string }
MongoDBCloudEnv represents ENV variables required for running tests against cloud
type RequestData ¶
type RequestData struct { Method string Path string Options api.RequestOptions }
RequestData represents a given request made to the MockClient
type ResponseBody ¶
ResponseBody is a io.ReadCloser that can be used as a net/http.Body
func NewAuthResponseBody ¶
func NewAuthResponseBody(data auth.Response) *ResponseBody
NewAuthResponseBody returns a new ResponseBody populated with auth.Response data
func NewResponseBody ¶
func NewResponseBody(data io.Reader) *ResponseBody
NewResponseBody returns a new ResponseBody
func (*ResponseBody) Close ¶
func (ar *ResponseBody) Close() error
Close satisfies the io.ReadCloser interface