print as html

This commit is contained in:
natercio committed 2026-10-05 15:08:00 +01:00
1 parent 62fe1a7076
commit 6703481dbb
9 files changed
+339 -20

No files matched your search

+31
View File
@@ -139,6 +139,37 @@ func TestRunWithIO_NoStateFileByDefault(t *testing.T) {
}
}
// TestRunWithIO_HTMLFormat verifies that --format html produces a complete
// HTML document on stdout starting with the DOCTYPE declaration.
func TestRunWithIO_HTMLFormat(t *testing.T) {
resetFlags(t)
t.Cleanup(func() { resetFlags(t) })
if err := pflag.Set("format", "html"); err != nil {
t.Fatalf("set format flag: %v", err)
}
var stdout bytes.Buffer
if err := runWithStdin(t, trading212SampleCSV, &stdout); err != nil {
t.Fatalf("runWithIO returned an error: %v\nstdout: %s", err, stdout.String())
}
got := stdout.String()
if !strings.HasPrefix(got, "<!DOCTYPE html>") {
t.Errorf("expected HTML output to start with <!DOCTYPE html>; got prefix: %q",
got[:min(len(got), 64)])
}
if !strings.Contains(got, "table-responsive") {
t.Errorf("expected output to contain Bootstrap table-responsive wrapper")
}
if !strings.Contains(got, "table-striped") {
t.Errorf("expected output to contain Bootstrap table-striped class")
}
if !strings.Contains(got, "</html>") {
t.Errorf("expected output to end with </html>")
}
}
// TestRunWithIO_UnsupportedPlatformForPersistence verifies that using
// --state-file with an unknown platform surfaces a clear error rather than
// silently falling back to EphemeralStore.