Documentation ¶
Overview ¶
Package dstest defines an interface for reading test cases from static files leveraging directories of test dataset input files & expected output files
Index ¶
- Constants
- Variables
- func BodyFilepath(dir string) (string, error)
- func DatasetChecksum(ds *dataset.Dataset) string
- func LoadTestCases(dir string) (tcs map[string]TestCase, err error)
- func ReadBodyData(dir string) ([]byte, string, error)
- func ReadDataset(dir, filename string) (*dataset.Dataset, error)
- func ReadInputTransformScript(dir string) ([]byte, string, error)
- func ReadInputVizScript(dir string) ([]byte, string, error)
- type TestCase
Constants ¶
const ( // InputDatasetFilename is the filename to use for an input dataset InputDatasetFilename = "input.dataset.json" // ExpectDatasetFilename is the filename to use to compare expected outputs ExpectDatasetFilename = "expect.dataset.json" // RenderedFilename is the file that represents an executed viz script RenderedFilename = "rendered.html" )
Variables ¶
var ( // PrivKey is a predefined private key for use in tests PrivKey crypto.PrivKey // PrivKeyPeerID is the base58-encoded multihash of PrivKey.PublicKey PrivKeyPeerID = "QmZePf5LeXow3RW5U1AgEiNbW46YnRGhZ7HPvm1UmPFPwt" )
Functions ¶
func BodyFilepath ¶
BodyFilepath retuns the path to the first valid data file it can find, which is a file named "data" that ends in an extension we support
func DatasetChecksum ¶
DatasetChecksum generates a fast, insecure hash of an encoded dataset, useful for checking that expected dataset values haven't changed
func LoadTestCases ¶
LoadTestCases loads a directory of case directories
func ReadBodyData ¶
ReadBodyData grabs input data
func ReadDataset ¶
ReadDataset grabs a dataset for a given dir for a given filename
func ReadInputTransformScript ¶
ReadInputTransformScript grabs input transform bytes
Types ¶
type TestCase ¶
type TestCase struct { // Path to the director on the local filesystem this test case is loaded from Path string // Name is the casename, should match directory name Name string // body.csv,body.json, etc BodyFilename string // test body in expected data format Body []byte // Filename of Transform Script TransformScriptFilename string // TransformScript bytes if one exists TransformScript []byte // Filename of Viz Script VizScriptFilename string // VizScript bytes if one exists VizScript []byte // Input is intended file for test input // loads from input.dataset.json Input *dataset.Dataset // Expect should match test output // loads from expect.dataset.json Expect *dataset.Dataset }
TestCase is a dataset test case, usually built from a directory of files for use in tests. All files are optional for TestCase, but may be required by the test itself.
func NewTestCaseFromDir ¶
NewTestCaseFromDir creates a test case from a directory of static test files dir should be the path to the directory to check, and any parsing errors will be logged using t.Log methods
func (TestCase) RenderedFile ¶
RenderedFile returns a qfs.File of the rendered file if one exists
func (TestCase) TransformScriptFile ¶
TransformScriptFile creates a qfs.File from testCase transform script data