Assert Validator

Assert Validator

Looker 6.20 introduced Data Tests, the ability to specify unit test-like assertions in Looker expression syntax. With data tests, you can declare logical assumptions that should always pass.

Within Spectacles, you can run all data tests for your project using the Assert validator.

Running the Assert validator

To run the Assert validator, you must specify the LookML project and Git branch to test in addition to your API credentials. As with your API credentials, these can be set via the command line (--project and --branch), environment variables (LOOKER_PROJECT and LOOKER_GIT_BRANCH), or a YAML file.

Once the desired project and branch have been set, run Assert validation as follows:

spectacles assert \
	--base-url https://company_name.looker.com \
	--client-id HpB53crD3DMDkdJPCRc \
	--client-secret jDRSM6ZGG9D5WH3r5FynQ9c \
	--project thelook \
	--branch dev-john-doe-294a
spectacles assert
spectacles assert --config-file looker_configuration.yml

In the next section, we’ll learn how to deploy Spectacles in a production continuous integration pipeline.

Exit Codes

If every Explore passes, the Assert validator will exit with code 0. If any test fails, it will exit with code 102.

👉 Next: Deploying