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 MockRealmClient
- func (msc *MockRealmClient) AddSecret(groupID, appID string, secret secrets.Secret) error
- func (msc *MockRealmClient) Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
- func (msc *MockRealmClient) CopyAsset(groupID, appID, fromPath, toPath string) error
- func (msc *MockRealmClient) CreateDraft(groupID, appID string) (*models.AppDraft, error)
- func (msc *MockRealmClient) CreateEmptyApp(groupID, appName, locationName, deploymentModelName string) (*models.App, error)
- func (msc *MockRealmClient) DeleteAsset(groupID, appID, path string) error
- func (msc *MockRealmClient) DeployDraft(groupID, appID, draftID string) (*models.Deployment, error)
- func (msc *MockRealmClient) Diff(groupID, appID string, appData []byte, strategy string) ([]string, error)
- func (msc *MockRealmClient) DiscardDraft(groupID, appID, draftID string) error
- func (msc *MockRealmClient) DraftDiff(groupID, appID, draftID string) (*models.DraftDiff, error)
- func (msc *MockRealmClient) Export(groupID, appID string, strategy api.ExportStrategy) (string, io.ReadCloser, error)
- func (msc *MockRealmClient) ExportDependencies(groupID, appID string) (string, io.ReadCloser, error)
- func (msc *MockRealmClient) FetchAppByClientAppID(clientAppID string) (*models.App, error)
- func (msc *MockRealmClient) FetchAppByGroupIDAndClientAppID(groupID, clientAppID string) (*models.App, error)
- func (msc *MockRealmClient) FetchAppsByGroupID(groupID string) ([]*models.App, error)
- func (msc *MockRealmClient) GetDeployment(groupID, appID, deploymentID string) (*models.Deployment, error)
- func (msc *MockRealmClient) GetDrafts(groupID, appID string) ([]models.AppDraft, error)
- func (msc *MockRealmClient) Import(groupID, appID string, appData []byte, strategy string) error
- func (msc *MockRealmClient) InvalidateCache(groupID, appID, path string) error
- func (msc *MockRealmClient) ListAssetsForAppID(groupID, appID string) ([]hosting.AssetMetadata, error)
- func (msc *MockRealmClient) ListSecrets(groupID, appID string) ([]secrets.Secret, error)
- func (msc *MockRealmClient) MoveAsset(groupID, appID, fromPath, toPath string) error
- func (msc *MockRealmClient) RemoveSecretByID(groupID, appID, secretID string) error
- func (msc *MockRealmClient) RemoveSecretByName(groupID, appID, secretName string) error
- func (msc *MockRealmClient) SetAssetAttributes(groupID, appID, path string, attributes ...hosting.AssetAttribute) error
- func (msc *MockRealmClient) UpdateSecretByID(groupID, appID, secretID, secretValue string) error
- func (msc *MockRealmClient) UpdateSecretByName(groupID, appID, secretName, secretValue string) error
- func (msc *MockRealmClient) UploadAsset(groupID, appID, path, hash string, size int64, body io.Reader, ...) error
- func (msc *MockRealmClient) 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 REALM_NO_SKIP_TEST is set, indicating that skipping is not permitted.
func NewEmptyStorage ¶
NewEmptyStorage creates a new empty MemoryStrategy
func NewPopulatedDeprecatedStorage ¶
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 MockRealmClient ¶
type MockRealmClient 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 }
MockRealmClient satisfies an api.RealmClient
func (*MockRealmClient) AddSecret ¶
func (msc *MockRealmClient) AddSecret(groupID, appID string, secret secrets.Secret) error
AddSecret adds a secret to the app
func (*MockRealmClient) Authenticate ¶
func (msc *MockRealmClient) Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
Authenticate will authenticate a user given an auth.AuthenticationProvider
func (*MockRealmClient) CopyAsset ¶
func (msc *MockRealmClient) CopyAsset(groupID, appID, fromPath, toPath string) error
CopyAsset copies an asset
func (*MockRealmClient) CreateDraft ¶
func (msc *MockRealmClient) CreateDraft(groupID, appID string) (*models.AppDraft, error)
CreateDraft returns a mock AppDraft
func (*MockRealmClient) CreateEmptyApp ¶
func (msc *MockRealmClient) CreateEmptyApp(groupID, appName, locationName, deploymentModelName string) (*models.App, error)
CreateEmptyApp does nothing
func (*MockRealmClient) DeleteAsset ¶
func (msc *MockRealmClient) DeleteAsset(groupID, appID, path string) error
DeleteAsset deletes an asset
func (*MockRealmClient) DeployDraft ¶
func (msc *MockRealmClient) DeployDraft(groupID, appID, draftID string) (*models.Deployment, error)
DeployDraft returns a mock Deployment
func (*MockRealmClient) Diff ¶
func (msc *MockRealmClient) 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 (*MockRealmClient) DiscardDraft ¶
func (msc *MockRealmClient) DiscardDraft(groupID, appID, draftID string) error
DiscardDraft does nothing
func (*MockRealmClient) DraftDiff ¶
func (msc *MockRealmClient) DraftDiff(groupID, appID, draftID string) (*models.DraftDiff, error)
DraftDiff returns an empty DraftDiff
func (*MockRealmClient) Export ¶
func (msc *MockRealmClient) Export(groupID, appID string, strategy api.ExportStrategy) (string, io.ReadCloser, error)
Export will download a Realm app as a .zip
func (*MockRealmClient) ExportDependencies ¶
func (msc *MockRealmClient) ExportDependencies(groupID, appID string) (string, io.ReadCloser, error)
Export will download a Realm app's dependencies
func (*MockRealmClient) FetchAppByClientAppID ¶
func (msc *MockRealmClient) FetchAppByClientAppID(clientAppID string) (*models.App, error)
FetchAppByClientAppID fetches a Realm app given a clientAppID
func (*MockRealmClient) FetchAppByGroupIDAndClientAppID ¶
func (msc *MockRealmClient) FetchAppByGroupIDAndClientAppID(groupID, clientAppID string) (*models.App, error)
FetchAppByGroupIDAndClientAppID fetches a Realm app given a groupID and clientAppID
func (*MockRealmClient) FetchAppsByGroupID ¶
func (msc *MockRealmClient) FetchAppsByGroupID(groupID string) ([]*models.App, error)
FetchAppsByGroupID does nothing
func (*MockRealmClient) GetDeployment ¶
func (msc *MockRealmClient) GetDeployment(groupID, appID, deploymentID string) (*models.Deployment, error)
GetDeployment returns a mock Deployment
func (*MockRealmClient) GetDrafts ¶
func (msc *MockRealmClient) GetDrafts(groupID, appID string) ([]models.AppDraft, error)
GetDrafts returns an empty list of AppDrafts
func (*MockRealmClient) Import ¶
func (msc *MockRealmClient) Import(groupID, appID string, appData []byte, strategy string) error
Import will push a local Realm app to the server
func (*MockRealmClient) InvalidateCache ¶
func (msc *MockRealmClient) InvalidateCache(groupID, appID, path string) error
InvalidateCache requests cache invalidation for the asset at the argued path
func (*MockRealmClient) ListAssetsForAppID ¶
func (msc *MockRealmClient) ListAssetsForAppID(groupID, appID string) ([]hosting.AssetMetadata, error)
ListAssetsForAppID fetches a Realm app given a clientAppID
func (*MockRealmClient) ListSecrets ¶
func (msc *MockRealmClient) ListSecrets(groupID, appID string) ([]secrets.Secret, error)
ListSecrets lists the secrets of an app
func (*MockRealmClient) MoveAsset ¶
func (msc *MockRealmClient) MoveAsset(groupID, appID, fromPath, toPath string) error
MoveAsset moves an asset
func (*MockRealmClient) RemoveSecretByID ¶
func (msc *MockRealmClient) RemoveSecretByID(groupID, appID, secretID string) error
RemoveSecretByID removes a secret from the app
func (*MockRealmClient) RemoveSecretByName ¶
func (msc *MockRealmClient) RemoveSecretByName(groupID, appID, secretName string) error
RemoveSecretByName removes a secret from the app
func (*MockRealmClient) SetAssetAttributes ¶
func (msc *MockRealmClient) SetAssetAttributes(groupID, appID, path string, attributes ...hosting.AssetAttribute) error
SetAssetAttributes sets an asset's attributes
func (*MockRealmClient) UpdateSecretByID ¶
func (msc *MockRealmClient) UpdateSecretByID(groupID, appID, secretID, secretValue string) error
UpdateSecretByID updates a secret from the app
func (*MockRealmClient) UpdateSecretByName ¶
func (msc *MockRealmClient) UpdateSecretByName(groupID, appID, secretName, secretValue string) error
UpdateSecretByName updates a secret from the app
func (*MockRealmClient) UploadAsset ¶
func (msc *MockRealmClient) UploadAsset(groupID, appID, path, hash string, size int64, body io.Reader, attributes ...hosting.AssetAttribute) error
UploadAsset uploads an asset
func (*MockRealmClient) UploadDependencies ¶
func (msc *MockRealmClient) UploadDependencies(groupID, appID, fullPath string) error
type MongoDBCloudEnv ¶
type MongoDBCloudEnv struct { CloudAPIBaseURL string RealmServerBaseURL 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