♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
GarfieldandCopilot committed 2026-11-16 14:07:45 +08:00
1 parent 6379a117c2
commit 0174664163
15 files changed
+47 -47

No files matched your search

+7 -7
View File
@@ -23,7 +23,7 @@ Assert.eq(book.authors, "作者甲、作者乙")
Assert.eq(book.intro, "宣传语 & 引言\n\n第一段。\n第二段:完整简介结尾。")
Assert.eq(book.cover, wire.artwork)
Assert.eq(book.meta.rating.score, 8.9)
Assert.eq(book.meta.rating.by, "ext.zhihu")
Assert.eq(book.meta.rating.by, "zhihu")
Assert.is_nil(Mapper.detail({ error = { code = 1 }, title = "错误" }, "11"))
Assert.is_nil(Mapper.detail(wire, "11", { show_score = false, score = "8.9" }).meta)
Assert.is_nil(Mapper.detail(wire, "11", { show_score = true, score = "11" }).meta)
@@ -42,7 +42,7 @@ package.loaded["http.request"] = {
end,
}
local Settings = require("utils.settings")
Settings.getSource("ext.zhihu").cookie = "z_c0=fixture"
Settings.getSource("zhihu").cookie = "z_c0=fixture"
local Client = require("moonsource_zhihu.client")
local result, err, calls = nil, nil, 0
local function done(value, reason) result, err, calls = value, reason, calls + 1 end
@@ -79,20 +79,20 @@ pending[#pending].cb(JSON.encode(grading))
Assert.eq(calls, before, "取消后迟到的评分不能更新详情")
local BookDB = require("book.books_db")
Assert.is_true(BookDB.upsertLocal({ source_id = "ext.zhihu", stable_id = "11", title = "本地书名", category = "本地分类" }))
Assert.is_true(BookDB.upsertLocal({ source_id = "zhihu", stable_id = "11", title = "本地书名", category = "本地分类" }))
package.loaded["moonsource_zhihu.client"] = {
detailAsync = function(id, cb) cb(Mapper.detail(wire, id, grading)); return {} end,
}
local source = require("moonsource_zhihu.source").new()
source:getDetailAsync({ source_id = "ext.zhihu", stable_id = "11" }, done)
source:getDetailAsync({ source_id = "zhihu", stable_id = "11" }, done)
Assert.eq(result.authors, "作者甲、作者乙", "本地上架的脏行也要补缺失作者")
Assert.eq(result.intro, book.intro, "本地上架时没有简介,详情必须补全并落盘")
Assert.eq(result.title, "本地书名")
Assert.eq(result.category, "本地分类")
Assert.eq(result.sync_status, 0)
Assert.is_true(BookDB.upsertLocal({ source_id = "ext.zhihu", stable_id = "11", title = "自定义书名",
Assert.is_true(BookDB.upsertLocal({ source_id = "zhihu", stable_id = "11", title = "自定义书名",
authors = "自定义作者", intro = "自定义简介", category = "本地分类" }))
source:getDetailAsync({ source_id = "ext.zhihu", stable_id = "11" }, done)
source:getDetailAsync({ source_id = "zhihu", stable_id = "11" }, done)
Assert.eq(result.authors, "自定义作者")
Assert.eq(result.intro, "自定义简介", "自动补全不能覆盖已编辑的非空字段")
Settings.getSource("ext.zhihu").cookie = nil
Settings.getSource("zhihu").cookie = nil