Helpers for making test assertions

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
sizethe size attribute of the test targetNone
timeoutthe timeout attribute of the test targetNone

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“.”

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