mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
test: add unit tests for docsettings
This commit is contained in:
committed by
Frans de Jonge
parent
0871100367
commit
2aa9d5d64e
2
Makefile
2
Makefile
@@ -119,7 +119,7 @@ coverage: $(INSTALL_DIR)/koreader/.luacov
|
||||
--coverage --exclude-tags=nocov
|
||||
# coverage report summary
|
||||
cd $(INSTALL_DIR)/koreader && tail -n \
|
||||
+$$(($$(grep -nm1 Summary luacov.report.out|cut -d: -f1)-1)) \
|
||||
+$$(($$(grep -nm1 -e "^Summary$$" luacov.report.out|cut -d: -f1)-1)) \
|
||||
luacov.report.out
|
||||
|
||||
fetchthirdparty:
|
||||
|
||||
@@ -2,6 +2,7 @@ local lfs = require("libs/libkoreader-lfs")
|
||||
local DataStorage = require("datastorage")
|
||||
local dump = require("dump")
|
||||
local purgeDir = require("ffi/util").purgeDir
|
||||
local logger = require("logger")
|
||||
|
||||
local DocSettings = {}
|
||||
|
||||
@@ -24,6 +25,7 @@ function DocSettings:getSidecarDir(doc_path)
|
||||
end
|
||||
-- We shouldn't be called with anything but files with registered
|
||||
-- extensions, but in case we are, return something useful
|
||||
logger.err("getSidecarFile called with unexpected path:", doc_path)
|
||||
return doc_path..".sdr"
|
||||
end
|
||||
|
||||
|
||||
@@ -14,6 +14,15 @@ describe("docsettings module", function()
|
||||
assert.Equals("baz.sdr", docsettings:getSidecarDir("baz.pdf"))
|
||||
end)
|
||||
|
||||
it("should generate sidecar metadata file", function()
|
||||
assert.Equals("../../foo.sdr/metadata.pdf.lua",
|
||||
docsettings:getSidecarFile("../../foo.pdf"))
|
||||
assert.Equals("/foo/bar.sdr/metadata.pdf.lua",
|
||||
docsettings:getSidecarFile("/foo/bar.pdf"))
|
||||
assert.Equals("baz.sdr/metadata.epub.lua",
|
||||
docsettings:getSidecarFile("baz.epub"))
|
||||
end)
|
||||
|
||||
it("should read legacy history file", function()
|
||||
local file = "file.pdf"
|
||||
local d = docsettings:open(file)
|
||||
|
||||
Reference in New Issue
Block a user