Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertToFilterParams(filter *FilterResource) map[string]string
- type Attribute
- type Client
- func (c *Client) FinishLaunch(id string, launch *FinishExecutionRQ) (*FinishLaunchRS, error)
- func (c *Client) FinishLaunchRaw(id string, body json.RawMessage) (*FinishLaunchRS, error)
- func (c *Client) FinishTest(id string, rq *FinishTestRQ) (*MsgRS, error)
- func (c *Client) FinishTestRaw(id string, body json.RawMessage) (*MsgRS, error)
- func (c *Client) GetFiltersByName(name string) (*FilterPage, error)
- func (c *Client) GetLaunches() (*LaunchPage, error)
- func (c *Client) GetLaunchesByFilter(filter map[string]string) (*LaunchPage, error)
- func (c *Client) GetLaunchesByFilterName(name string) (*LaunchPage, error)
- func (c *Client) GetLaunchesByFilterString(filter string) (*LaunchPage, error)
- func (c *Client) MergeLaunches(rq *MergeLaunchesRQ) (*LaunchResource, error)
- func (c *Client) SaveLog(log *SaveLogRQ) (*EntryCreatedRS, error)
- func (c *Client) SaveLogMultipart(log *SaveLogRQ, files map[string]*os.File) (*EntryCreatedRS, error)
- func (c *Client) StartChildTest(parent string, item *StartTestRQ) (*EntryCreatedRS, error)
- func (c *Client) StartChildTestRaw(parent string, body json.RawMessage) (*EntryCreatedRS, error)
- func (c *Client) StartLaunch(launch *StartLaunchRQ) (*EntryCreatedRS, error)
- func (c *Client) StartLaunchRaw(body json.RawMessage) (*EntryCreatedRS, error)
- func (c *Client) StartTest(item *StartTestRQ) (*EntryCreatedRS, error)
- func (c *Client) StartTestRaw(body json.RawMessage) (*EntryCreatedRS, error)
- func (c *Client) StopLaunch(id string) (*MsgRS, error)
- type EntryCreatedRS
- type FilterEntity
- type FilterOrder
- type FilterPage
- type FilterResource
- type FilterSelectionParam
- type FinishExecutionRQ
- type FinishLaunchRS
- type FinishTestRQ
- type LaunchMode
- type LaunchPage
- type LaunchResource
- type MergeLaunchesRQ
- type MergeType
- type MsgRS
- type Parameter
- type Response
- type SaveLogRQ
- type StartLaunchRQ
- type StartLaunchRS
- type StartRQ
- type StartTestRQ
- type Statistics
- type Status
- type TestItemType
- type Timestamp
Examples ¶
Constants ¶
const ( LogLevelDebug = "DEBUG" LogLevelInfo = "INFO" )
Client constants
Variables ¶
var LaunchModes = launchModeValuesType{
Default: "DEFAULT",
Debug: "DEBUG",
}
LaunchModes is enum values for easy access
var MergeTypes = mergeTypeValuesType{
Deep: "DEEP",
Basic: "BASIC",
}
MergeTypes is enum values for easy access
var Statuses = statusValuesType{
Passed: "PASSED",
Failed: "FAILED",
Stopped: "STOPPED",
Skipped: "SKIPPED",
Interrupted: "INTERRUPTED",
Canceled: "CANCELLED",
Info: "INFO",
Warn: "WARN",
}
Statuses is enum values for easy access
var TestItemTypes = testItemTypeValuesType{
Suite: "SUITE",
Story: "STORY",
Test: "TEST",
Scenario: "SCENARIO",
Step: "STEP",
BeforeClass: "BEFORE_CLASS",
BeforeGroups: "BEFORE_GROUPS",
BeforeMethod: "BEFORE_METHOD",
BeforeSuite: "BEFORE_SUITE",
BeforeTest: "BEFORE_TEST",
AfterClass: "AFTER_CLASS",
AfterGroups: "AFTER_GROUPS",
AfterMethod: "AFTER_METHOD",
AfterSuite: "AFTER_SUITE",
AfterTest: "AFTER_TEST",
}
TestItemTypes is enum values for easy access
Functions ¶
func ConvertToFilterParams ¶
func ConvertToFilterParams(filter *FilterResource) map[string]string
ConvertToFilterParams converts RP internal filter representation to query string
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is ReportPortal REST API Client
Example ¶
package main import ( "log" "os" "time" "github.com/google/uuid" ) func main() { client := NewClient("xxx", "xxx", "xxx") launchUUID := uuid.New() launch, err := client.StartLaunch(&StartLaunchRQ{ Mode: LaunchModes.Default, StartRQ: StartRQ{ Name: "gorp-test", UUID: &launchUUID, StartTime: Timestamp{Time: time.Now()}, Description: "Demo Launch", }, }) checkErr(err, "unable to start launch") testUUID := uuid.New() _, err = client.StartTest(&StartTestRQ{ LaunchID: launch.ID, CodeRef: "example_test.go", UniqueID: "another one unique ID", Retry: false, Type: TestItemTypes.Test, StartRQ: StartRQ{ Name: "Gorp Test", StartTime: Timestamp{time.Now()}, UUID: &testUUID, }, }) checkErr(err, "unable to start test") log.Println("LAUNCHXXX") log.Println(launchUUID.String()) _, err = client.SaveLog(&SaveLogRQ{ LaunchUUID: launchUUID.String(), ItemID: testUUID.String(), Level: LogLevelInfo, LogTime: Timestamp{time.Now()}, Message: "Log without binary", }) checkErr(err, "unable to save log") file, _ := os.Open("../go.mod") _, err = client.SaveLogMultipart(&SaveLogRQ{ LaunchUUID: launchUUID.String(), ItemID: testUUID.String(), Level: LogLevelInfo, Message: "Log with binary", }, map[string]*os.File{"go.mod": file}) checkErr(err, "unable to save log multipart") _, err = client.FinishTest(testUUID.String(), &FinishTestRQ{ LaunchUUID: launchUUID.String(), FinishExecutionRQ: FinishExecutionRQ{ EndTime: Timestamp{time.Now()}, Status: Statuses.Passed, }, }) checkErr(err, "unable to finish test") _, err = client.FinishLaunch(launchUUID.String(), &FinishExecutionRQ{ Status: Statuses.Passed, EndTime: Timestamp{time.Now()}, }) checkErr(err, "unable to finish launch") } func checkErr(err error, msg string) { if err != nil { log.Fatal(msg, err) } }
Output:
func NewClient ¶
NewClient creates new instance of Client host - server hostname project - name of the project uuid - User Token (see user profile page)
func (*Client) FinishLaunch ¶
func (c *Client) FinishLaunch(id string, launch *FinishExecutionRQ) (*FinishLaunchRS, error)
FinishLaunch finishes launch in RP
func (*Client) FinishLaunchRaw ¶
func (c *Client) FinishLaunchRaw(id string, body json.RawMessage) (*FinishLaunchRS, error)
FinishLaunchRaw finishes launch in RP with body in form of bytes buffer
func (*Client) FinishTest ¶
func (c *Client) FinishTest(id string, rq *FinishTestRQ) (*MsgRS, error)
FinishTest finishes test in RP
func (*Client) FinishTestRaw ¶
FinishTestRaw finishes test in RP accepting body as array of bytes
func (*Client) GetFiltersByName ¶
func (c *Client) GetFiltersByName(name string) (*FilterPage, error)
GetFiltersByName retrieves filter by its name
func (*Client) GetLaunches ¶
func (c *Client) GetLaunches() (*LaunchPage, error)
GetLaunches retrieves latest launches
func (*Client) GetLaunchesByFilter ¶
func (c *Client) GetLaunchesByFilter(filter map[string]string) (*LaunchPage, error)
GetLaunchesByFilter retrieves launches by filter
func (*Client) GetLaunchesByFilterName ¶
func (c *Client) GetLaunchesByFilterName(name string) (*LaunchPage, error)
GetLaunchesByFilterName retrieves launches by filter name
func (*Client) GetLaunchesByFilterString ¶
func (c *Client) GetLaunchesByFilterString(filter string) (*LaunchPage, error)
GetLaunchesByFilterString retrieves launches by filter as string
func (*Client) MergeLaunches ¶
func (c *Client) MergeLaunches(rq *MergeLaunchesRQ) (*LaunchResource, error)
MergeLaunches merge two launches
func (*Client) SaveLog ¶
func (c *Client) SaveLog(log *SaveLogRQ) (*EntryCreatedRS, error)
SaveLog attaches log in RP
func (*Client) SaveLogMultipart ¶
func (c *Client) SaveLogMultipart(log *SaveLogRQ, files map[string]*os.File) (*EntryCreatedRS, error)
SaveLogMultipart attaches log in RP
func (*Client) StartChildTest ¶
func (c *Client) StartChildTest(parent string, item *StartTestRQ) (*EntryCreatedRS, error)
StartChildTest starts new test in RP
func (*Client) StartChildTestRaw ¶
func (c *Client) StartChildTestRaw(parent string, body json.RawMessage) (*EntryCreatedRS, error)
StartChildTestRaw starts new test in RP accepting request body as array of bytes
func (*Client) StartLaunch ¶
func (c *Client) StartLaunch(launch *StartLaunchRQ) (*EntryCreatedRS, error)
StartLaunch starts new launch in RP
func (*Client) StartLaunchRaw ¶
func (c *Client) StartLaunchRaw(body json.RawMessage) (*EntryCreatedRS, error)
StartLaunchRaw starts new launch in RP with body in form of bytes buffer
func (*Client) StartTest ¶
func (c *Client) StartTest(item *StartTestRQ) (*EntryCreatedRS, error)
StartTest starts new test in RP
func (*Client) StartTestRaw ¶
func (c *Client) StartTestRaw(body json.RawMessage) (*EntryCreatedRS, error)
StartTestRaw starts new test in RP accepting request body as array of bytes
type EntryCreatedRS ¶
type EntryCreatedRS struct {
ID string `json:"id,omitempty"`
}
EntryCreatedRS payload
type FilterEntity ¶
type FilterEntity struct { Field string `json:"filtering_field"` Condition string `json:"condition"` Value string `json:"value"` }
FilterEntity - One piece of filter
type FilterOrder ¶
FilterOrder - Describes ordering
type FilterPage ¶
type FilterPage struct { Content []*FilterResource Response }
FilterPage - GET Filter response model
type FilterResource ¶
type FilterResource struct { ID string `json:"id"` Name string `json:"name"` Type TestItemType `json:"type"` Owner string `json:"owner"` Entities []*FilterEntity `json:"entities"` SelectionParams *FilterSelectionParam `json:"selection_parameters,omitempty"` }
FilterResource - GET Filter response model
type FilterSelectionParam ¶
type FilterSelectionParam struct { PageNumber int `json:"page_number"` Orders []*FilterOrder `json:"orders,omitempty"` }
FilterSelectionParam - Describes filter ordering
type FinishExecutionRQ ¶
type FinishExecutionRQ struct { EndTime Timestamp `json:"end_time,omitempty"` Status Status `json:"status,omitempty"` Description string `json:"description,omitempty"` Attributes []*Attribute `json:"attribute,omitempty"` }
FinishExecutionRQ payload representation
type FinishLaunchRS ¶
type FinishLaunchRS struct { EntryCreatedRS Number int64 `json:"number,omitempty"` Link string `json:"link,omitempty"` }
FinishLaunchRS is finish execution payload
type FinishTestRQ ¶
type FinishTestRQ struct { FinishExecutionRQ LaunchUUID string `json:"launchUuid,omitempty"` TestCaseID string `json:"testCaseId,omitempty"` Retry bool `json:"retry,omitempty"` RetryOf string `json:"retryOf,omitempty"` }
FinishTestRQ payload representation
type LaunchPage ¶
type LaunchPage struct { Content []*LaunchResource Response }
LaunchPage - GET Launch response model
type LaunchResource ¶
type LaunchResource struct { ID int `json:"id"` UUID string `json:"uuid"` Name string `json:"name,omitempty"` Number int `json:"number"` Description string `json:"description,omitempty"` StartTime Timestamp `json:"startTime,omitempty"` EndTime Timestamp `json:"endTime,omitempty"` Status Status `json:"status,omitempty"` Attributes []*Attribute `json:"attributes,omitempty"` Mode LaunchMode `json:"mode,omitempty"` ApproximateDuration float32 `json:"approximateDuration,omitempty"` HasRetries bool `json:"hasRetries,omitempty"` Statistics *Statistics `json:"statistics,omitempty"` Analyzers []string `json:"analysing,omitempty"` // nolint:misspell // defined as described on server end }
LaunchResource - GET Launch response model
type MergeLaunchesRQ ¶
type MergeLaunchesRQ struct { Description string `json:"description,omitempty"` StartTime *Timestamp `json:"startTime,omitempty"` EndTime *Timestamp `json:"endTime,omitempty"` ExtendSuitesDescription bool `json:"extendSuitesDescription,omitempty"` Launches []int `json:"launches"` MergeType MergeType `json:"mergeType,omitempty"` Mode string `json:"mode,omitempty"` Tags []string `json:"tags,omitempty"` Name string `json:"name,omitempty"` }
MergeLaunchesRQ payload representation
type MsgRS ¶
type MsgRS struct {
Msg string `json:"msg,omitempty"`
}
MsgRS successful operation response payload
type Response ¶
type Response struct { // Page is a slice of data returned by server Page struct { Number int `json:"number,omitempty"` Size int `json:"size,omitempty"` TotalElements int `json:"totalElements,omitempty"` TotalPages int `json:"totalPages,omitempty"` } `json:"page,omitempty"` }
Response is a representation of server response
type SaveLogRQ ¶
type SaveLogRQ struct { LaunchUUID string `json:"launchUuid,omitempty"` ItemID string `json:"itemUuid,omitempty"` LogTime Timestamp `json:"time,omitempty"` Message string `json:"message,omitempty"` Level string `json:"level,omitempty"` }
SaveLogRQ payload representation. Without attaches.
type StartLaunchRQ ¶
type StartLaunchRQ struct { StartRQ Mode LaunchMode `json:"mode"` Rerun bool `json:"rerun,omitempty"` RerunOf *uuid.UUID `json:"rerunOf,omitempty"` }
StartLaunchRQ payload representation
type StartLaunchRS ¶
type StartLaunchRS struct {
ID string `json:"id,omitempty"`
}
StartLaunchRS payload
type StartRQ ¶
type StartRQ struct { UUID *uuid.UUID `json:"uuid,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Attributes []*Attribute `json:"attributes,omitempty"` StartTime Timestamp `json:"start_time,omitempty"` }
StartRQ payload representation
type StartTestRQ ¶
type StartTestRQ struct { StartRQ CodeRef string `json:"codeRef,omitempty"` Parameters []*Parameter `json:"parameters,omitempty"` UniqueID string `json:"uniqueId,omitempty"` TestCaseID string `json:"testCaseId,omitempty"` LaunchID string `json:"launchUuid,omitempty"` Type TestItemType `json:"type,omitempty"` Retry bool `json:"retry,omitempty"` HasStats string `json:"hasStats,omitempty"` }
StartTestRQ payload representation
type Statistics ¶
type Statistics struct { Executions map[string]int `json:"executions,omitempty"` Defects map[string]map[string]int `json:"defects,omitempty"` }
Statistics is a execution stat details
type Timestamp ¶
Timestamp is a wrapper around Time to support Epoch milliseconds
func (*Timestamp) MarshalJSON ¶
MarshalJSON converts Epoch milliseconds (timestamp) to appropriate object
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON converts Epoch milliseconds (timestamp) to appropriate object