Documentation ¶
Overview ¶
Package test provides test doubles that implement some of nb interfaces. Authors of nb-extension packages are encouraged to use them as they make for a uniform test code across different packages. See it's example usages in schema/**/*_test.go files.
Index ¶
- Variables
- func DisplayData(s, mt string) schema.Cell
- func ErrorOutput(s string) schema.Cell
- func ExecuteResult(s, mt string, n int) schema.Cell
- func Markdown(s string) schema.Cell
- func Notebook(cs ...schema.Cell) schema.Notebook
- func Raw(s, mt string) schema.Cell
- func Stderr(s string) schema.Cell
- func Stdout(s string) schema.Cell
- func WithAttachment(c schema.Cell, filename string, mimebundle map[string]interface{}) interface{ ... }
- type Cell
- type CodeCell
- type ExecuteResultOutput
Constants ¶
This section is empty.
Variables ¶
var NoWrapper = render.WithCellRenderers(&fakeWrapper{})
NoWrapper overrides the default cell wrapper so that the cell content could be compared directly without parsing the surrounding wrap. Useful for testing extensions.
Functions ¶
func DisplayData ¶
DisplayData creates schema.DisplayData cell with source s and reported mime-type mt.
func ErrorOutput ¶
ErrorOutput creates schema.Error cell with source s and mime-type common.Stderr.
func ExecuteResult ¶
ExecuteResult creates schema.ExecuteResult cell with source s, reported mime-type mt and execution count n.
func WithAttachment ¶
func WithAttachment(c schema.Cell, filename string, mimebundle map[string]interface{}) interface { schema.Cell schema.HasAttachments }
WithAttachments creates a cell that has an attachment.
The underlying test implementation for schema.MimeBundle accesses its keys in a random order and should always be created with 1 element only to keep test outcomes stable and predictable.
Example:
test.WithAttachments( test.Markdown("![img](attachment:photo:png)"), "photo.png", map[string]interface{"image/png": "base64-encoded-image"} )
Types ¶
type Cell ¶
type Cell struct { CellType schema.CellType Mime string // mime-type (avoid name-clash with the interface method) Source []byte }
Cell is a test fixture to mock schema.Cell.
type CodeCell ¶
CodeCell is a test fixture to mock schema.CodeCell. Use cases which only require schema.Cell, should create &test.Cell{CT: schema.Code} instead.
func (*CodeCell) ExecutionCount ¶
type ExecuteResultOutput ¶
ExecuteResultOutput is a test fixture to mock cell outputs with ExecuteResult type.
func (*ExecuteResultOutput) ExecutionCount ¶
func (ex *ExecuteResultOutput) ExecutionCount() int