Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
package vidmod
import (
"encoding/json"
"strings"
"testing"
)
func TestWatchConsumeReqVideoIDCompatibility(t *testing.T) {
tests := []struct {
body string
want string
}{
{body: `{"videoId":"new-field"}`, want: "new-field"},
{body: `{"vid":"legacy-field"}`, want: "legacy-field"},
{body: `{"videoId":"new-field","vid":"legacy-field"}`, want: "new-field"},
}
for _, tt := range tests {
var req WatchConsumeReq
if err := json.Unmarshal([]byte(tt.body), &req); err != nil {
t.Fatal(err)
}
if got := req.GetVideoID(); got != tt.want {
t.Fatalf("GetVideoID() = %q, want %q", got, tt.want)
}
}
}
func TestWatchConsumeRespJSON(t *testing.T) {
data, err := json.Marshal(WatchConsumeResp{
IsCan: true,
WatchCount: 2,
TotalWatchCount: 3,
Consumed: false,
})
if err != nil {
t.Fatal(err)
}
for _, field := range []string{
`"isCan":true`,
`"watchCount":2`,
`"totalWatchCount":3`,
`"consumed":false`,
} {
if !strings.Contains(string(data), field) {
t.Fatalf("%s missing from response: %s", field, data)
}
}
}