test(sterni/mblog/golden): check mblog against expected output
This should allow for refactors with more confidence as we can make sure
base functionality stays the same. It is important to test image
extraction, so unfortunately we need to check in a base64 rendering of
an image file. I've used //users/tvlbot.jpg, so git should at least be
able to deduplicate the extracted content. Note that this was achieved
by altering the note message since I wasn't able to add the picture in
the iOS Notes.app without the image being recompressed.
To get extra benefit, we also add the test note to the mime4cl test suite.
The expected output can be updated with
mblog $(mg build :maildir) expected
Change-Id: I0aa493b206439018ad89745bacbd47af78bd1396
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12911
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
024783f535
commit
b8e4da856f
6 changed files with 396 additions and 0 deletions
41
users/sterni/mblog/golden/default.nix
Normal file
41
users/sterni/mblog/golden/default.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
# SPDX-FileCopyrightText: Copyright (C) 2024 by sterni
|
||||
{ depot, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
maildir = pkgs.runCommandNoCC "mblog-golden-example-maildir" { } ''
|
||||
mkdir -p "$out/cur"
|
||||
cp --reflink=auto \
|
||||
"${depot.path.origSrc + "/third_party/lisp/mime4cl/test/samples/mail-note.msg"}" \
|
||||
"$out/cur/1732277542.274467_1.wolfgang,U=1:2,S"
|
||||
'';
|
||||
|
||||
# Make golden test based on the given mblog derivation and add subtarget
|
||||
# golden tests for all meta.ci.targets.
|
||||
makeGoldenTest = mblog:
|
||||
pkgs.runCommand "mblog-golden-tests"
|
||||
{
|
||||
passthru = {
|
||||
inherit maildir;
|
||||
} // lib.mapAttrs (_: makeGoldenTest) (
|
||||
lib.attrsets.getAttrs mblog.meta.ci.targets mblog
|
||||
);
|
||||
|
||||
nativeBuildInputs = [
|
||||
mblog
|
||||
];
|
||||
|
||||
meta.ci = {
|
||||
inherit (mblog.meta.ci) targets;
|
||||
};
|
||||
}
|
||||
''
|
||||
mkdir -p actual
|
||||
mblog ${maildir} actual
|
||||
|
||||
diff --color=always -ru ${./expected} actual
|
||||
touch "$out"
|
||||
'';
|
||||
in
|
||||
|
||||
makeGoldenTest depot.users.sterni.mblog
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head><meta charset='utf-8'><meta viewport='width=device-width'><title>example note</title><link rel='stylesheet' type='text/css' href='../style.css'></head><body><header><nav><a href='..'>index</a></nav></header><main><article><DIV><U>example note</U></DIV><DIV><BR></DIV><DIV><B>bold </B><I>italic</I> <I><B>bold & italic</B></I> <STRIKE>strikethrough</STRIKE></DIV><DIV><STRIKE><BR></STRIKE></DIV><DIV><STRIKE><IMG SRC="IMG_1637.JPG"></STRIKE></DIV><DIV><STRIKE><BR></STRIKE></DIV><DIV>It is technically possible to create arbitrary (?) HTML markup via copy & paste from e.g. a browser. Let’s not test that for now.</DIV></article></main></body></html>
|
||||
2
users/sterni/mblog/golden/expected/index.html
Normal file
2
users/sterni/mblog/golden/expected/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head><meta charset='utf-8'><meta viewport='width=device-width'><title>mblog</title><link rel='stylesheet' type='text/css' href='style.css'></head><body><header><nav><a href=''>index</a></nav></header><main><h1>mblog</h1><table><tr><td><a href='d81cb91d-c210-46b1-835a-6a7c34db666b'>example note</a></td><td>2024-11-22T11·49+00</td></tr></table></main></body></html>
|
||||
13
users/sterni/mblog/golden/expected/style.css
Normal file
13
users/sterni/mblog/golden/expected/style.css
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
header, main {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
main img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
color: blue;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue