Helpers for making test assertions

assert_archive_contains

Assert that an archive file contains at least the given file entries.

PARAMETERS

NameDescriptionDefault Value
namename of the resulting sh_test targetnone
archiveLabel of the the .tar or .zip filenone
expecteda (partial) file listing, either as a Label of a file containing it, or a list of stringsnone
type“tar” or “zip”. If None, a type will be inferred from the filename.None
kwargsadditional named arguments for the resulting sh_testnone

assert_contains

Generates a test target which fails if the file doesn't contain the string.

Depends on bash, as it creates an sh_test target.

PARAMETERS

NameDescriptionDefault Value
nametarget to createnone
actualLabel of a filenone
expecteda string which should appear in the filenone
sizestandard attribute for tests“small”
kwargsadditional named arguments for the resulting sh_testnone

assert_directory_contains

Assert that a directory contains at least the given file entries.

PARAMETERS

NameDescriptionDefault Value
namename of the resulting sh_test targetnone
directoryLabel of the directory artifactnone
expecteda (partial) file listing, either as a Label of a file containing it, or a list of stringsnone
kwargsadditional named arguments for the resulting sh_testnone

assert_json_matches

Assert that the given json files have the same semantic content.

Uses jq to filter each file. The default value of "." as the filter means to compare the whole file.

See the jq rule for more about the filter expressions as well as setup notes for the jq toolchain.

PARAMETERS

NameDescriptionDefault Value
namename of resulting diff_test targetnone
file1a json filenone
file2another json filenone
filter1a jq filter to apply to file1“.”
filter2a jq filter to apply to file2“.”
kwargsadditional named arguments for the resulting diff_testnone

assert_outputs

Assert that the default outputs of a target are the expected ones.

PARAMETERS

NameDescriptionDefault Value
namename of the resulting diff_testnone
actualstring of the label to check the outputsnone
expecteda list of rootpaths of expected outputs, as they would appear in a runfiles manifestnone
kwargsadditional named arguments for the resulting diff_testnone