Documentation ¶
Index ¶
- Variables
- func GenerateValidAccessToken() string
- func MustSkipf(t *testing.T, format string, args ...interface{})
- func NewEmptyStorage() *storage.Storage
- func NewPopulatedStorage(apiKey, 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) Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
- func (msc *MockStitchClient) CreateEmptyApp(groupID, appName string) (*models.App, error)
- func (msc *MockStitchClient) Diff(groupID, appID string, appData []byte, strategy string) ([]string, error)
- func (msc *MockStitchClient) Export(groupID, appID string, isTemplated bool) (string, io.ReadCloser, error)
- func (msc *MockStitchClient) FetchAppByClientAppID(clientAppID string) (*models.App, error)
- func (msc *MockStitchClient) FetchAppsByGroupID(groupID string) ([]*models.App, error)
- func (msc *MockStitchClient) Import(groupID, appID string, appData []byte, strategy 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 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 string) (*models.App, error) FetchAppByClientAppIDFn func(clientAppID string) (*models.App, error) FetchAppsByGroupIDFn func(groupID string) ([]*models.App, error) ExportFn func(groupID, appID string, isTemplated bool) (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) }
MockStitchClient satisfies an api.StitchClient
func (*MockStitchClient) Authenticate ¶
func (msc *MockStitchClient) Authenticate(authProvider auth.AuthenticationProvider) (*auth.Response, error)
Authenticate will authenticate a user given an auth.AuthenticationProvider
func (*MockStitchClient) CreateEmptyApp ¶
func (msc *MockStitchClient) CreateEmptyApp(groupID, appName string) (*models.App, error)
CreateEmptyApp does nothing
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) Export ¶
func (msc *MockStitchClient) Export(groupID, appID string, isTemplated bool) (string, io.ReadCloser, error)
Export will download a Stitch app as a .zip
func (*MockStitchClient) FetchAppByClientAppID ¶
func (msc *MockStitchClient) FetchAppByClientAppID(clientAppID string) (*models.App, error)
FetchAppByClientAppID fetches a Stitch app given a clientAppID
func (*MockStitchClient) FetchAppsByGroupID ¶
func (msc *MockStitchClient) FetchAppsByGroupID(groupID string) ([]*models.App, error)
FetchAppsByGroupID does nothing
type MongoDBCloudEnv ¶
type MongoDBCloudEnv struct { CloudAPIBaseURL string StitchServerBaseURL string APIKey string Username 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