feat(test):新增管理端API自动化测试
This commit is contained in:
1 parent
706b2da5b4
commit
104f1de0b3
36 files changed
+4195
No files matched your search
@@ -0,0 +1,69 @@
|
||||
//go:build integration
|
||||
|
||||
package admin_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/qianfree/team-api/tests/integration/admin/testinfra"
|
||||
)
|
||||
|
||||
func TestErrorLogList(t *testing.T) {
|
||||
client := testinfra.GetAuthedClient(t)
|
||||
|
||||
resp := client.Get("/api/admin/error-logs", map[string]string{
|
||||
"page": "1",
|
||||
"page_size": "10",
|
||||
})
|
||||
testinfra.AssertPaginatedList(t, resp, 0)
|
||||
}
|
||||
|
||||
func TestErrorLogListWithFilters(t *testing.T) {
|
||||
client := testinfra.GetAuthedClient(t)
|
||||
|
||||
// Filter by source
|
||||
resp := client.Get("/api/admin/error-logs", map[string]string{
|
||||
"page": "1",
|
||||
"page_size": "10",
|
||||
"source": "relay",
|
||||
})
|
||||
resp.AssertSuccess(t)
|
||||
|
||||
// Filter by resolved status
|
||||
resp = client.Get("/api/admin/error-logs", map[string]string{
|
||||
"page": "1",
|
||||
"page_size": "10",
|
||||
"resolved": "false",
|
||||
})
|
||||
resp.AssertSuccess(t)
|
||||
|
||||
// Filter by error_code
|
||||
resp = client.Get("/api/admin/error-logs", map[string]string{
|
||||
"page": "1",
|
||||
"page_size": "10",
|
||||
"error_code": "500",
|
||||
})
|
||||
resp.AssertSuccess(t)
|
||||
|
||||
// Filter by keyword
|
||||
resp = client.Get("/api/admin/error-logs", map[string]string{
|
||||
"page": "1",
|
||||
"page_size": "10",
|
||||
"keyword": "timeout",
|
||||
})
|
||||
resp.AssertSuccess(t)
|
||||
|
||||
t.Logf("Error log filters applied successfully")
|
||||
}
|
||||
|
||||
func TestErrorLogStats(t *testing.T) {
|
||||
client := testinfra.GetAuthedClient(t)
|
||||
|
||||
resp := client.Get("/api/admin/error-logs/stats", nil)
|
||||
resp.AssertSuccess(t)
|
||||
|
||||
var data map[string]any
|
||||
resp.DecodeData(t, &data)
|
||||
|
||||
t.Logf("Error log stats returned %d keys", len(data))
|
||||
}
|
||||
Reference in new issue
Block a user