Files
rootandClaude Opus 4.7 79ac89b458 Initial commit
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-11-07 10:47:18 +08:00

32 lines
1.0 KiB
Go

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)
}
})
}
}