Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package playletser
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPlayletHotLikeRespMatchesSwaggerFields(t *testing.T) {
|
||||
const raw = `{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"hotSearch": [{"keyword": "都市", "count": 18}],
|
||||
"guessLike": [{"id": 12, "title": "示例短剧", "slug": "example"}]
|
||||
}
|
||||
}`
|
||||
|
||||
var env APIEnvelope[PlayletHotLikeResp]
|
||||
if err := json.Unmarshal([]byte(raw), &env); err != nil {
|
||||
t.Fatalf("unmarshal hot-like response: %v", err)
|
||||
}
|
||||
if env.Code != 200 || len(env.Data.HotSearch) != 1 || env.Data.HotSearch[0].Keyword != "都市" || env.Data.HotSearch[0].Count != 18 {
|
||||
t.Fatalf("unexpected hot search data: %#v", env)
|
||||
}
|
||||
if len(env.Data.GuessLike) != 1 || env.Data.GuessLike[0].ID != 12 || env.Data.GuessLike[0].Slug != "example" {
|
||||
t.Fatalf("unexpected guess-like data: %#v", env.Data.GuessLike)
|
||||
}
|
||||
if hotLikePath != "/api/app/playlet/hot-like" {
|
||||
t.Fatalf("hotLikePath = %q", hotLikePath)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user