@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user