-
Notifications
You must be signed in to change notification settings - Fork 59
/
flaky_tests.go
48 lines (40 loc) · 1.38 KB
/
flaky_tests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package buildkite
import (
"context"
"fmt"
)
// FlakyTestsService handles communication with flaky test related
// methods of the Buildkite Test Analytics API.
//
// Buildkite API docs: https://buildkite.com/docs/apis/rest-api/analytics/flaky-tests
type FlakyTestsService struct {
client *Client
}
type FlakyTest struct {
ID string `json:"id,omitempty"`
WebURL string `json:"web_url,omitempty"`
Scope string `json:"scope,omitempty"`
Name string `json:"name,omitempty"`
Location string `json:"location,omitempty"`
FileName string `json:"file_name,omitempty"`
Instances int `json:"instances,omitempty"`
MostRecentInstanceAt *Timestamp `json:"most_recent_instance_at,omitempty"`
}
type FlakyTestsListOptions struct{ ListOptions }
func (fts *FlakyTestsService) List(ctx context.Context, org, slug string, opt *FlakyTestsListOptions) ([]FlakyTest, *Response, error) {
u := fmt.Sprintf("v2/analytics/organizations/%s/suites/%s/flaky-tests", org, slug)
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}
req, err := fts.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}
var flakyTests []FlakyTest
resp, err := fts.client.Do(req, &flakyTests)
if err != nil {
return nil, resp, err
}
return flakyTests, resp, err
}