Documentation
¶
Overview ¶
Package rainforest is a golang client for the Rainforest QA API
Index ¶
- type Browser
- type Client
- func (c *Client) AddGeneratorRows(targetGenerator *Generator, rowData []map[int]string) error
- func (c *Client) AddGeneratorRowsFromTable(targetGenerator *Generator, targetColumns []string, rowData [][]string) error
- func (c *Client) CheckRunStatus(runID int) (*RunStatus, error)
- func (c *Client) CreateRun(params RunParams) (*RunStatus, error)
- func (c *Client) CreateTabularVar(name, description string, columns []string, singleUse bool) (*Generator, error)
- func (c *Client) CreateTemporaryEnvironment(urlString string) (*Environment, error)
- func (c *Client) CreateTest(test *RFTest) error
- func (c *Client) DeleteGenerator(genID int) error
- func (c *Client) DeleteTest(testID int) error
- func (c *Client) DeleteTestByRFMLID(testRFMLID string) error
- func (c *Client) Do(req *http.Request, out interface{}) (*http.Response, error)
- func (c *Client) GetBrowsers() ([]Browser, error)
- func (c *Client) GetFolders() ([]Folder, error)
- func (c *Client) GetGenerators() ([]Generator, error)
- func (c *Client) GetRFMLIDs() (TestIDMappings, error)
- func (c *Client) GetRunDetails(runID int) (*RunDetails, error)
- func (c *Client) GetRunTestDetails(runID int, testID int) (*RunTestDetails, error)
- func (c *Client) GetSites() ([]Site, error)
- func (c *Client) GetTest(testID int) (*RFTest, error)
- func (c *Client) GetTests(params *RFTestFilters) ([]RFTest, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) ParseEmbeddedFiles(test *RFTest) error
- func (c *Client) UpdateTest(test *RFTest) error
- type Environment
- type EnvironmentParams
- type Folder
- type Generator
- type GeneratorColumn
- type GeneratorRelatedTests
- type RFEmbeddedTest
- type RFMLReader
- type RFMLWriter
- type RFTest
- type RFTestFilters
- type RFTestStep
- type RunBrowserDetails
- type RunDetails
- type RunFeedback
- type RunParams
- type RunStateDetails
- type RunStatus
- type RunStepDetails
- type RunTestDetails
- type Site
- type TestIDMap
- type TestIDMappings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Browser ¶
Browser type represents a single browser returned by the API call for a list of browsers
type Client ¶
type Client struct {
// URL of a Rainforest API endpoint to be used by the client
BaseURL *url.URL
// String that will be set as an user agent with current library version appended to it
UserAgent string
// Client token used for authenticating requests made to the RF
ClientToken string
// Save HTTP Response Headers
LastResponseHeaders http.Header
// contains filtered or unexported fields
}
Client is responsible for communicating with Rainforest API
func NewClient ¶
NewClient constructs a new rainforest API Client. As a parameter takes client token which is used for authentication and is available in the rainforest web app.
func (*Client) AddGeneratorRows ¶
AddGeneratorRows adds rows to the specified tabular variable rowData is in a form of [{ 123: "foo", 124: "bar" }, { 123: "baz", 124: "qux" }] where 123 is a column ID AddGeneratorRowsFromTable is also provided which accepts different rowData format
func (*Client) AddGeneratorRowsFromTable ¶
func (c *Client) AddGeneratorRowsFromTable(targetGenerator *Generator, targetColumns []string, rowData [][]string) error
AddGeneratorRowsFromTable adds rows to the specified tabular variable data should be formatted as follows: targetColumns contains names of existing columns to which add data e.g. ["login", "password"] rowData contains row data in columns order specified in targetColumns e.g. [["foo", "bar"], ["baz", "qux"]]
func (*Client) CheckRunStatus ¶
CheckRunStatus returns the status of a specified run.
func (*Client) CreateTabularVar ¶
func (c *Client) CreateTabularVar(name, description string, columns []string, singleUse bool) (*Generator, error)
CreateTabularVar creates new tabular variable on RF and returns Generator associated with it columns argument should contain just an array of column names, contents of the generator should be filled using AddGeneratorRows.
func (*Client) CreateTemporaryEnvironment ¶
func (c *Client) CreateTemporaryEnvironment(urlString string) (*Environment, error)
CreateTemporaryEnvironment creates a new temporary environment and returns the Environment.
func (*Client) CreateTest ¶
CreateTest creates new test on RF, requires RFTest struct to be prepared to upload using helpers
func (*Client) DeleteGenerator ¶
DeleteGenerator deletes generator with specified ID
func (*Client) DeleteTest ¶
DeleteTest deletes test with a specified ID from the RF test suite
func (*Client) DeleteTestByRFMLID ¶
DeleteTestByRFMLID deletes test with a specified RFMLID from the RF test suite
func (*Client) Do ¶
Do sends out the request to the API and unpacks JSON response to the out variable.
func (*Client) GetBrowsers ¶
GetBrowsers returns a slice of Browsers which are available for the client to run RF tests against.
func (*Client) GetFolders ¶
GetFolders returns a slice of Folders (their names and IDs) which are available for filtering RF tests.
func (*Client) GetGenerators ¶
GetGenerators fetches a list of all available generators for the account
func (*Client) GetRFMLIDs ¶
func (c *Client) GetRFMLIDs() (TestIDMappings, error)
GetRFMLIDs returns all tests IDs and RFML IDs to properly map tests to their IDs for uploading and deleting.
func (*Client) GetRunDetails ¶
func (c *Client) GetRunDetails(runID int) (*RunDetails, error)
GetRunDetails returns the top level details of a Run
func (*Client) GetRunTestDetails ¶
func (c *Client) GetRunTestDetails(runID int, testID int) (*RunTestDetails, error)
GetRunTestDetails returns the detailed information for a RunTest
func (*Client) GetTests ¶
func (c *Client) GetTests(params *RFTestFilters) ([]RFTest, error)
GetTests returns all tests that are optionally filtered by RFTestFilters
func (*Client) NewRequest ¶
NewRequest creates an API request. Provided url will be resolved using ResolveReference, which works in a similar way to the hrefs in a browser (most important takeaway is to not add preceeding slash to the link as it resolves to a root path of domain). The body argument is JSON endoded and attached as a request body. This function also attaches auth token from the client to the request.
func (*Client) ParseEmbeddedFiles ¶
ParseEmbeddedFiles replaces file step variable paths with values expected by Rainforest. eg: {{ file.screenshot(my_screenshot.gif) }} would be translated to the format {{ file.screenshot(FILE_ID, FILE_SIGNATURE) }}.
func (*Client) UpdateTest ¶
UpdateTest updates existing test on RF, requires RFTest struct to be prepared to upload using helpers
type Environment ¶
Environment represents an environment in Rainforest
type EnvironmentParams ¶
EnvironmentParams are the parameters used to create a new Environment
type Generator ¶
type Generator struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"generator_type,omitempty"`
SingleUse bool `json:"single_use,omitempty"`
Columns []GeneratorColumn `json:"columns,omitempty"`
RowCount int `json:"row_count,omitempty"`
}
Generator is a type representing generators which can be used as variables in RF tests. They can be builtin or uploaded by customer as a tabular variable.
func (Generator) GetDescription ¶
GetDescription returns the Generator's description
type GeneratorColumn ¶
type GeneratorColumn struct {
ID int `json:"id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
Name string `json:"name,omitempty"`
}
GeneratorColumn is a type of column in a generator
type GeneratorRelatedTests ¶
type GeneratorRelatedTests struct {
ID int `json:"id,omitempty"`
Title string `json:"title,omitempty"`
}
GeneratorRelatedTests is a type which holds tests where the generator has been used
type RFEmbeddedTest ¶
RFEmbeddedTest contains an embedded test details
type RFMLReader ¶
type RFMLReader struct {
// Version sets the RFML spec version, it's set by NewRFMLReader to the newest one.
Version int
// Sets the default value of redirect, that's used when it's not specified in RFML
RedirectDefault bool
// contains filtered or unexported fields
}
RFMLReader reads form RFML formatted file. It exports some settings that can be set before parsing.
func NewRFMLReader ¶
func NewRFMLReader(r io.Reader) *RFMLReader
NewRFMLReader returns RFML parser based on passed io.Reader - typically a RFML file.
func (*RFMLReader) ReadAll ¶
func (r *RFMLReader) ReadAll() (*RFTest, error)
ReadAll parses whole RFML file using RFML version specified by Version parameter of reader and returns resulting RFTest
type RFMLWriter ¶
type RFMLWriter struct {
// Version sets the RFML spec version
Version int
// contains filtered or unexported fields
}
RFMLWriter writes a RFML formatted test to a given file.
func NewRFMLWriter ¶
func NewRFMLWriter(w io.Writer) *RFMLWriter
NewRFMLWriter returns RFML writer based on passed io.Writer - typically a RFML file.
func (*RFMLWriter) WriteRFMLTest ¶
func (r *RFMLWriter) WriteRFMLTest(test *RFTest) error
WriteRFMLTest writes a given RFTest to its writer in the given RFML version.
type RFTest ¶
type RFTest struct {
TestID int `json:"id"`
RFMLID string `json:"rfml_id"`
Source string `json:"source"`
Title string `json:"title,omitempty"`
StartURI string `json:"start_uri"`
SiteID int `json:"site_id,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags"`
BrowsersMap []map[string]interface{} `json:"browsers"`
Elements []testElement `json:"elements,omitempty"`
// Browsers and Steps are helper fields
Browsers []string `json:"-"`
Steps []interface{} `json:"-"`
// RFMLPath is a helper field for keeping track of the filepath to the
// test's RFML file.
RFMLPath string `json:"-"`
}
RFTest is a struct representing the Rainforest Test with its settings and steps
func (*RFTest) HasUploadableFiles ¶
HasUploadableFiles returns true if test has embedded files in the format {{ file.screenshot(path/to/file) }} or {{ file.download(path/to/file) }}. It returns false otherwise.
func (*RFTest) PrepareToUploadFromRFML ¶
func (t *RFTest) PrepareToUploadFromRFML(mappings TestIDMappings) error
PrepareToUploadFromRFML uses different helper methods to prepare struct for API upload
func (*RFTest) PrepareToWriteAsRFML ¶
func (t *RFTest) PrepareToWriteAsRFML(mappings TestIDMappings) error
PrepareToWriteAsRFML uses different helper methods to prepare struct for translation to RFML
type RFTestFilters ¶
RFTestFilters are used to translate test filters to a proper query string
type RFTestStep ¶
RFTestStep contains single Rainforest step
type RunBrowserDetails ¶
type RunBrowserDetails struct {
Name string `json:"name"`
Feedback []RunFeedback `json:"feedback"`
}
RunBrowserDetails contains details about a Browser of a Run Step
type RunDetails ¶
type RunDetails struct {
ID int `json:"id"`
Description string `json:"description"`
TotalTests int `json:"total_tests"`
TotalFailedTests int `json:"total_failed_tests"`
TotalNoResultTests int `json:"total_no_result_tests"`
StateDetails RunStateDetails `json:"state_details"`
Timestamps map[string]time.Time `json:"timestamps"`
Tests []RunTestDetails
}
RunDetails contains top level details of a Run
type RunFeedback ¶
type RunFeedback struct {
AnswerGiven string `json:"answer_given"`
JobState string `json:"job_state"`
Note string `json:"note"`
}
RunFeedback contains details about the feedback of a Run Step for a browser
type RunParams ¶
type RunParams struct {
// This can be eiter []int or string containing 'all'
Tests interface{} `json:"tests,omitempty"`
Tags []string `json:"tags,omitempty"`
SmartFolderID int `json:"smart_folder_id,omitempty"`
SiteID int `json:"site_id,omitempty"`
Crowd string `json:"crowd,omitempty"`
Conflict string `json:"conflict,omitempty"`
Browsers []string `json:"browsers,omitempty"`
Description string `json:"description,omitempty"`
EnvironmentID int `json:"environment_id,omitempty"`
}
RunParams is a struct holding all potential parameters needed to start a new RF run.
type RunStateDetails ¶
RunStateDetails contains details about the state of a Run
type RunStatus ¶
type RunStatus struct {
ID int `json:"id"`
State string `json:"state"`
StateDetails struct {
Name string `json:"name"`
IsFinalState bool `json:"is_final_state"`
} `json:"state_details"`
Result string `json:"result"`
CurrentProgress struct {
Percent int `json:"percent"`
Total int `json:"total"`
Complete int `json:"complete"`
NoResult int `json:"no_result"`
} `json:"current_progress"`
FrontendURL string `json:"frontend_url,omitempty"`
}
RunStatus represents a status of a RF run in progress.
type RunStepDetails ¶
type RunStepDetails struct {
Browsers []RunBrowserDetails `json:"browsers"`
}
RunStepDetails contains details about a Run Step
type RunTestDetails ¶
type RunTestDetails struct {
ID int `json:"id"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Result string `json:"result"`
Steps []RunStepDetails `json:"steps"`
}
RunTestDetails contains details about a Run Test
type TestIDMappings ¶
type TestIDMappings []TestIDMap
TestIDMappings is a slice of all the mapping pairs. And has a set of functions defined to get map of one to the other.
func (TestIDMappings) MapIDtoRFMLID ¶
func (s TestIDMappings) MapIDtoRFMLID() map[int]string
MapIDtoRFMLID creates a map from test IDs to RFML IDs
func (TestIDMappings) MapRFMLIDtoID ¶
func (s TestIDMappings) MapRFMLIDtoID() map[string]int
MapRFMLIDtoID creates a map from RFML IDs to IDs