init: web_hgdjc_server

This commit is contained in:
2026-11-07 10:44:09 +08:00
commit 71a4f4e175
713 changed files with 147749 additions and 0 deletions
@@ -0,0 +1,31 @@
package srv_aicomment
import (
"testing"
"videoweb/pub/models/aicommentrecord"
)
func TestResumeAICommentVideo(t *testing.T) {
tests := []struct {
name string
current int64
records aicommentrecord.AiCommentRecordList
want int
ok bool
}{
{name: "new playlet", want: 3, ok: true},
{name: "existing comments", current: 2, want: 1, ok: true},
{name: "already full", current: 3},
{name: "submitted task", records: aicommentrecord.AiCommentRecordList{{Status: aicommentrecord.StatusSubmitted, RetainCount: 3}}},
{name: "failed task can retry", records: aicommentrecord.AiCommentRecordList{{Status: aicommentrecord.StatusFailed, RetainCount: 3}}, want: 3, ok: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, ok := resumeAICommentVideo(VideoItem{CurrentCount: tt.current}, tt.records)
if ok != tt.ok || (ok && got.CommentTotal != tt.want) {
t.Fatalf("resumeAICommentVideo() = (%d, %v), want (%d, %v)", got.CommentTotal, ok, tt.want, tt.ok)
}
})
}
}