print as html
This commit is contained in:
1 parent
bb00676452
commit
3b971cda61
9 files changed
+339
-7
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user