-
Notifications
You must be signed in to change notification settings - Fork 42
/
test.go
48 lines (42 loc) · 1.35 KB
/
test.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 testrail
import "strconv"
// Test represent a Test
type Test struct {
AssignedToID int `json:"assignedto_id"`
CaseID int `json:"case_id"`
Estimate string `json:"estimate"`
EstimateForecast string `json:"estimate_forecast"`
ID int `json:"id"`
MilestoneID int `json:"milestone_id"`
PriorityID int `json:"priority_id"`
Refs string `json:"refs"`
RunID int `json:"run_id"`
StatusID int `json:"status_id"`
Title string `json:"title"`
TypeID int `json:"type_id"`
}
type Tests struct {
Tests []Test `json:"tests"`
}
// GetTest returns the test testID
func (c *Client) GetTest(testID int) (Test, error) {
returnTest := Test{}
err := c.sendRequest("GET", "get_test/"+strconv.Itoa(testID), nil, &returnTest)
return returnTest, err
}
// GetTests returns the list of tests of runID
// with status statusID, if specified
func (c *Client) GetTests(runID int, statusID ...[]int) ([]Test, error) {
returnTest := Tests{}
uri := "get_tests/" + strconv.Itoa(runID)
if len(statusID) > 0 {
uri = applySpecificFilter(uri, "status_id", statusID[0])
}
var err error
if c.useBetaApi {
err = c.sendRequestBeta("GET", uri, nil, &returnTest, "tests")
} else {
err = c.sendRequest("GET", uri, nil, &returnTest)
}
return returnTest.Tests, err
}