api

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package api provides an API client for the Test Plan API.

Index

Constants

This section is empty.

Variables

View Source
var ErrRetryTimeout = errors.New("request retry timeout")

Functions

This section is empty.

Types

type BillingError

type BillingError struct {
	Message string
}

func (*BillingError) Error

func (e *BillingError) Error() string

type Client

type Client struct {
	OrganizationSlug string
	ServerBaseUrl    string
	// contains filtered or unexported fields
}

client is a client for the test plan API. It contains the organization slug, server base URL, and an HTTP client.

func NewClient

func NewClient(cfg ClientConfig) *Client

NewClient creates a new client for the test plan API with the given configuration. It also creates an HTTP client with an authTransport middleware.

func (Client) CreateTestPlan

func (c Client) CreateTestPlan(ctx context.Context, suiteSlug string, params TestPlanParams) (plan.TestPlan, error)

CreateTestPlan creates a test plan from the server. ErrRetryTimeout is returned if the client failed to communicate with the server after exceeding the retry limit.

func (*Client) DoWithRetry

func (c *Client) DoWithRetry(ctx context.Context, reqOptions httpRequest, v interface{}) (*http.Response, error)

DoWithRetry sends http request with retries. Successful API response (status code 200) is JSON decoded and stored in the value pointed to by v. The request will be retried when the server returns 429 or 5xx status code, or when there is a network error. After reaching the retry timeout, the function will return ErrRetryTimeout. The request will not be retried when the server returns 4xx status code, and the error message will be returned as an error.

func (Client) FetchFilesTiming

func (c Client) FetchFilesTiming(ctx context.Context, suiteSlug string, files []string) (map[string]time.Duration, error)

FetchFilesTiming fetches the timing of the requested files from the server. The server only returns timings for the files that has been run before. ErrRetryTimeout is returned if the client failed to communicate with the server after exceeding the retry limit.

func (Client) FetchTestPlan

func (c Client) FetchTestPlan(ctx context.Context, suiteSlug string, identifier string, jobRetryCount int) (*plan.TestPlan, error)

FetchTestPlan fetchs a test plan from the server. ErrRetryTimeout is returned if the client failed to communicate with the server after exceeding the retry limit.

func (Client) FilterTests

func (c Client) FilterTests(ctx context.Context, suiteSlug string, params FilterTestsParams) ([]FilteredTest, error)

FilterTests filters tests from the server. It returns a list of tests that need to be split by example. Currently, it only filters tests that are slow.

func (Client) PostTestPlanMetadata

func (c Client) PostTestPlanMetadata(ctx context.Context, suiteSlug string, identifier string, params TestPlanMetadataParams) error

type ClientConfig

type ClientConfig struct {
	AccessToken      string
	OrganizationSlug string
	ServerBaseUrl    string
	Version          string
}

ClientConfig is the configuration for the test plan API client.

type FilterTestsParams

type FilterTestsParams struct {
	Files []plan.TestCase   `json:"files"`
	Env   map[string]string `json:"env"`
}

type FilteredTest

type FilteredTest struct {
	Path string `json:"path"`
}

type TestPlanMetadataParams

type TestPlanMetadataParams struct {
	Version    string               `json:"version"`
	Env        map[string]string    `json:"env"`
	Timeline   []Timeline           `json:"timeline"`
	Statistics runner.RunStatistics `json:"statistics"`
}

type TestPlanParams

type TestPlanParams struct {
	Runner      string             `json:"runner"`
	Identifier  string             `json:"identifier"`
	Parallelism int                `json:"parallelism"`
	Branch      string             `json:"branch"`
	Tests       TestPlanParamsTest `json:"tests"`
}

TestPlanParams represents the config params sent when fetching a test plan.

type TestPlanParamsTest

type TestPlanParamsTest struct {
	Files    []plan.TestCase `json:"files"`
	Examples []plan.TestCase `json:"examples,omitempty"`
}

type Timeline

type Timeline struct {
	Timestamp string `json:"timestamp"`
	Event     string `json:"event"`
}

Jump to

Keyboard shortcuts

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