Initial commit: web_hghl_server

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 16:28:14 +08:00
co-authored by Claude Opus 4.7
commit 65fca60622
653 changed files with 135901 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package searchapi
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"videoweb/pub/common/srvdef"
"github.com/gin-gonic/gin"
)
func TestSearchApiRejectsUnsupportedTypes(t *testing.T) {
for _, query := range []string{"type=1", "type=3", "type=2", "type=-1", "type=abc", "type="} {
writer := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(writer)
ctx.Request = httptest.NewRequest(http.MethodGet, "/search/?"+query, nil)
SearchApi(ctx)
var resp struct {
Code int64 `json:"code"`
}
if err := json.Unmarshal(writer.Body.Bytes(), &resp); err != nil {
t.Fatalf("参数 %s 的响应无法解析: %v", query, err)
}
if resp.Code != int64(srvdef.ErrParamError) {
t.Errorf("参数 %s 返回 code %d, want %d", query, resp.Code, srvdef.ErrParamError)
}
}
}