提交 234e9afd 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

rest api testing

上级 636654e1
......@@ -47,7 +47,9 @@ func (s *CaseApiSuite) TestCaseListByModuleApi(t provider.T) {
t.ID("7635")
token := httpHelper.Login()
url := zentaoHelper.GenApiUrl(fmt.Sprintf("/products/%d/testcases?module=%d", config.ProductId, config.ModuleId),
moduleId := getModuleMinId()
url := zentaoHelper.GenApiUrl(fmt.Sprintf("/products/%d/testcases?module=%d", config.ProductId, moduleId),
nil, constTestHelper.ZentaoSiteUrl)
bodyBytes, _ := httpHelper.Get(url, token)
......
......@@ -36,3 +36,21 @@ func (s *ModuleApiSuite) TestModuleListForCaseApi(t provider.T) {
t.Require().Greater(firstModuleId, int64(0), "list modules failed")
}
func getModuleMinId() (id int64) {
token := httpHelper.Login()
url := zentaoHelper.GenApiUrl(fmt.Sprintf("modules?type=case&id=%d", config.ProductId), nil, constTestHelper.ZentaoSiteUrl)
bodyBytes, _ := httpHelper.Get(url, token)
modules := gjson.Get(string(bodyBytes), "modules").Array()
for _, item := range modules {
itemId := item.Get("id").Int()
if id == 0 || (itemId > 0 && id > itemId) {
id = itemId
}
}
return
}
......@@ -49,3 +49,21 @@ func (s *SuiteApiSuite) TestSuiteDetailApi(t provider.T) {
t.Require().Greater(len(name), 0, "get testsuite failed")
}
func getSuiteMinId() (id int64) {
token := httpHelper.Login()
url := zentaoHelper.GenApiUrl(fmt.Sprintf("products/%d/testsuites", config.ProductId), nil, constTestHelper.ZentaoSiteUrl)
bodyBytes, _ := httpHelper.Get(url, token)
suites := gjson.Get(string(bodyBytes), "testsuites").Array()
for _, suite := range suites {
suiteId := suite.Get("id").Int()
if id == 0 || (suiteId > 0 && id > suiteId) {
id = suiteId
}
}
return
}
......@@ -64,3 +64,21 @@ func getLatestTaskId(token string) (id int) {
return
}
func getTaskMinId() (id int64) {
token := httpHelper.Login()
url := zentaoHelper.GenApiUrl(fmt.Sprintf("testtasks?product=%d", config.ProductId), nil, constTestHelper.ZentaoSiteUrl)
bodyBytes, _ := httpHelper.Get(url, token)
tasks := gjson.Get(string(bodyBytes), "testtasks").Array()
for _, task := range tasks {
taskId := task.Get("id").Int()
if id == 0 || (taskId > 0 && id > taskId) {
id = taskId
}
}
return
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册