rainforest

package
v2.0.0-alpha.4+incompa... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package rainforest is a golang client for the Rainforest QA API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Browser

type Browser struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Browser type represents a single browser returned by the API call for a list of browsers

func (Browser) GetDescription

func (b Browser) GetDescription() string

GetDescription returns the Browser description

func (Browser) GetID

func (b Browser) GetID() string

GetID returns the Browser name

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
	// contains filtered or unexported fields
}

Client is responsible for communicating with Rainforest API

func NewClient

func NewClient(token string) *Client

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

func (c *Client) AddGeneratorRows(targetGenerator *Generator, rowData []map[int]string) error

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

func (c *Client) CheckRunStatus(runID int) (*RunStatus, error)

CheckRunStatus returns the status of a specified run.

func (*Client) CreateRun

func (c *Client) CreateRun(params RunParams) (*RunStatus, error)

CreateRun starts a new RF run with given params.

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

func (c *Client) CreateTest(test *RFTest) error

CreateTest creates new test on RF, requires RFTest struct to be prepared to upload using helpers

func (*Client) DeleteGenerator

func (c *Client) DeleteGenerator(genID int) error

DeleteGenerator deletes generator with specified ID

func (*Client) DeleteTest

func (c *Client) DeleteTest(testID int) error

DeleteTest deletes test with a specified ID from the RF test suite

func (*Client) DeleteTestByRFMLID

func (c *Client) DeleteTestByRFMLID(testRFMLID string) error

DeleteTestByRFMLID deletes test with a specified RFMLID from the RF test suite

func (*Client) Do

func (c *Client) Do(req *http.Request, out interface{}) (*http.Response, error)

Do sends out the request to the API and unpacks JSON response to the out variable.

func (*Client) GetBrowsers

func (c *Client) GetBrowsers() ([]Browser, error)

GetBrowsers returns a slice of Browsers which are available for the client to run RF tests against.

func (*Client) GetFolders

func (c *Client) GetFolders() ([]Folder, error)

GetFolders returns a slice of Folders (their names and IDs) which are available for filtering RF tests.

func (*Client) GetGenerators

func (c *Client) GetGenerators() ([]Generator, error)

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) GetSites

func (c *Client) GetSites() ([]Site, error)

GetSites fetches sites available to use during the RF runs.

func (*Client) GetTest

func (c *Client) GetTest(testID int) (*RFTest, error)

GetTest gets a test from RF specified by the given test ID

func (*Client) GetTests

func (c *Client) GetTests(params *RFTestFilters) ([]RFTest, error)

GetTests returns all tests that are optionally filtered by RFTestFilters

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

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

func (c *Client) ParseEmbeddedFiles(test *RFTest) error

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

func (c *Client) UpdateTest(test *RFTest) error

UpdateTest updates existing test on RF, requires RFTest struct to be prepared to upload using helpers

type Environment

type Environment struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Environment represents an environment in Rainforest

type EnvironmentParams

type EnvironmentParams struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

EnvironmentParams are the parameters used to create a new Environment

type Folder

type Folder struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}

Folder type represents a single folder returned by the API call for a list of folders

func (Folder) GetDescription

func (f Folder) GetDescription() string

GetDescription returns the Folder name

func (Folder) GetID

func (f Folder) GetID() string

GetID returns the Folder ID

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

func (g Generator) GetDescription() string

GetDescription returns the Generator's description

func (Generator) GetID

func (g Generator) GetID() string

GetID returns the Generator name

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

type RFEmbeddedTest struct {
	RFMLID   string
	Redirect bool
}

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,omitempty"`
	SiteID      int                      `json:"site_id,omitempty"`
	Description string                   `json:"description,omitempty"`
	Tags        []string                 `json:"tags,omitempty"`
	BrowsersMap []map[string]interface{} `json:"browsers,omitempty"`
	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

func (t *RFTest) HasUploadableFiles() bool

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

type RFTestFilters struct {
	Tags          []string
	SiteID        int
	SmartFolderID int
}

RFTestFilters are used to translate test filters to a proper query string

type RFTestStep

type RFTestStep struct {
	Action   string
	Response string
	Redirect bool
}

RFTestStep contains single Rainforest step

type Resource

type Resource interface {
	GetID() string
	GetDescription() string
}

Resource interface is a standardized way of looking at the types returned from the resources list API. It treats every resource as a pair of ID and description of entity under this ID.

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

type RunStateDetails struct {
	Name         string `json:"name"`
	IsFinalState bool   `json:"is_final_state"`
}

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 Site

type Site struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Site type represents a single site returned by the API call for a list of sites

func (Site) GetDescription

func (s Site) GetDescription() string

GetDescription returns the Site name

func (Site) GetID

func (s Site) GetID() string

GetID returns the Site ID

type TestIDMap

type TestIDMap struct {
	ID     int    `json:"id"`
	RFMLID string `json:"rfml_id"`
}

TestIDMap is a type representing RF tests that contain the test definitions.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL