adding tests for page ranges

This commit is contained in:
Julien Neuhart
2019-10-05 12:09:39 +02:00
parent 827060b6ce
commit ca0784fa59
7 changed files with 89 additions and 8 deletions

View File

@@ -38,6 +38,26 @@ func TestHTMLPrinter(t *testing.T) {
assert.Nil(t, err)
err = os.RemoveAll(dest)
assert.Nil(t, err)
// options with a page ranges.
opts = DefaultChromePrinterOptions(config)
opts.PageRanges = "1"
p = NewHTMLPrinter(logger, fpath, opts)
dest = test.GenerateDestination()
err = p.Print(dest)
assert.Nil(t, err)
err = os.RemoveAll(dest)
assert.Nil(t, err)
// should not be OK as options have
// a wrong page ranges.
opts = DefaultChromePrinterOptions(config)
opts.PageRanges = "foo"
p = NewHTMLPrinter(logger, fpath, opts)
dest = test.GenerateDestination()
err = p.Print(dest)
test.AssertError(t, err)
assert.Equal(t, xerror.InvalidCode, xerror.Code(err))
err = os.RemoveAll(dest)
assert.Nil(t, err)
// should not be OK as context.Context
// should timeout.
opts = DefaultChromePrinterOptions(config)