This is a simple test runner for datahub jobs. It is designed to be used in a CI/CD pipeline to verify that jobs are working as expected.
This tool expects a manifest file to be present inside your datahub config project. The manifest file should contain a list of tests to run. For each test, the runner will spin up a new datahub, upload the defined required datasets, and run the job. It will then compare the output with the expected output.
djt path/to/manifest.json
package tests
import (
...
djt "github.com/mimiro-io/datahub-job-testing"
)
func TestMyJob(t *testing.T) {
...
manifest := "path/to/manifest.json"
tr := djt.NewTestRunner(manifest)
if ! tr.RunAllTests() {
// tests didn't pass
}
...
}
Each test case defined has the following properties:
{
"name": "Case1: Unique test name",
"description": "Description of the test case",
"includeCommon": true, # Include common configuration in this test run. Default is false
"jobPath": "relative/filepath/to/my/job.json",
"requiredDatasets": [
{
"name": "sdb.Animal",
"path": "tests/testdata/case1/sdb-Animal.json"
}
],
"expectedOutput": "tests/expected/myJob/case1.json"
}
Note: All file paths in the manifest file are relative to the repo root of the datahub config project
Some configuration is common to all tests. To add datasets for all test cases, use the top-level property common.requiredDatasets
. (See example manifest for details.)