-
Notifications
You must be signed in to change notification settings - Fork 59
/
test_runs.go
64 lines (53 loc) · 1.59 KB
/
test_runs.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package buildkite
import (
"context"
"fmt"
)
// TestRunsService handles communication with test run related
// methods of the Buildkite Test Analytics API.
//
// Buildkite API docs: https://buildkite.com/docs/apis/rest-api/analytics/runs
type TestRunsService struct {
client *Client
}
type TestRun struct {
ID string `json:"id,omitempty"`
URL string `json:"url,omitempty"`
WebURL string `json:"web_url,omitempty"`
Branch string `json:"branch,omitempty"`
CommitSHA string `json:"commit_sha,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}
type TestRunsListOptions struct {
ListOptions
}
func (trs *TestRunsService) List(ctx context.Context, org, slug string, opt *TestRunsListOptions) ([]TestRun, *Response, error) {
u := fmt.Sprintf("v2/analytics/organizations/%s/suites/%s/runs", org, slug)
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}
req, err := trs.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}
var testRuns []TestRun
resp, err := trs.client.Do(req, &testRuns)
if err != nil {
return nil, resp, err
}
return testRuns, resp, err
}
func (trs *TestRunsService) Get(ctx context.Context, org, slug, runID string) (TestRun, *Response, error) {
u := fmt.Sprintf("v2/analytics/organizations/%s/suites/%s/runs/%s", org, slug, runID)
req, err := trs.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return TestRun{}, nil, err
}
var testRun TestRun
resp, err := trs.client.Do(req, &testRun)
if err != nil {
return TestRun{}, resp, err
}
return testRun, resp, err
}