mirror of
https://github.com/bestnite/bilinovel-downloader.git
synced 2026-07-25 20:21:56 +00:00
- Upgrade playwright-go v0.5200.1 -> v0.6100.0 (module path changed from playwright-community to mxschmitt). The old Azure CDN driver download endpoint returns 404 for all versions; v0.6100.0 switches to npm registry which works correctly. - Fix file:// resource loading: replace absolute path src="/..." and href="/..." with full URLs so browser can fetch remote resources (chapterlog.js) when loading local HTML files. - Replace removed Devtools field with Args --auto-open-devtools-for-tabs. - Include error details in playwright install failure log. - Fix nil pointer in tests: check err before calling SetTextOnly. - Update all dependencies: goquery, templ, resty, cobra, pflag, etc. - Bump go toolchain 1.24.2 -> 1.25.0
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package test
|
|
|
|
import (
|
|
"bilinovel-downloader/downloader/bilinovel"
|
|
"encoding/json"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestBilinovel_GetNovel(t *testing.T) {
|
|
bilinovel, err := bilinovel.New(bilinovel.BilinovelNewOption{Concurrency: 5})
|
|
if err != nil {
|
|
t.Fatalf("failed to create bilinovel: %v", err)
|
|
}
|
|
bilinovel.SetTextOnly(true)
|
|
novel, err := bilinovel.GetNovel(2727, false, nil)
|
|
if err != nil {
|
|
t.Fatalf("failed to get novel: %v", err)
|
|
}
|
|
jsonBytes, err := json.Marshal(novel)
|
|
if err != nil {
|
|
t.Fatalf("failed to marshal novel: %v", err)
|
|
}
|
|
fmt.Println(string(jsonBytes))
|
|
}
|
|
|
|
func TestBilinovel_GetVolume(t *testing.T) {
|
|
bilinovel, err := bilinovel.New(bilinovel.BilinovelNewOption{Concurrency: 1})
|
|
if err != nil {
|
|
t.Fatalf("failed to create bilinovel: %v", err)
|
|
}
|
|
bilinovel.SetTextOnly(true)
|
|
volume, err := bilinovel.GetVolume(2727, 129092, false)
|
|
if err != nil {
|
|
t.Fatalf("failed to get volume: %v", err)
|
|
}
|
|
jsonBytes, err := json.Marshal(volume)
|
|
if err != nil {
|
|
t.Fatalf("failed to marshal volume: %v", err)
|
|
}
|
|
fmt.Println(string(jsonBytes))
|
|
}
|
|
|
|
func TestBilinovel_GetChapter(t *testing.T) {
|
|
bilinovel, err := bilinovel.New(bilinovel.BilinovelNewOption{Concurrency: 1})
|
|
if err != nil {
|
|
t.Fatalf("failed to create bilinovel: %v", err)
|
|
}
|
|
bilinovel.SetTextOnly(true)
|
|
chapter, err := bilinovel.GetChapter(2727, 129092, 129094)
|
|
if err != nil {
|
|
t.Fatalf("failed to get chapter: %v", err)
|
|
}
|
|
jsonBytes, err := json.Marshal(chapter)
|
|
if err != nil {
|
|
t.Fatalf("failed to marshal chapter: %v", err)
|
|
}
|
|
fmt.Println(string(jsonBytes))
|
|
}
|