Skip to main content

Atlas Testing

dataset csv​

dataset.csv attributes​

Name and descriptionRequiredValue

batch

Maximum number of rows written per statement. Defaults to 1000.

falseint

exclude

Skip the dataset tables matching the glob patterns.

false

List of strings

include

Load only the dataset tables matching the glob patterns (orders, public.*).

false

List of strings

sample

Sample each table: load its first rows in the snapshot, up to this number, and the rows of the other loaded tables they reference, so no foreign key is left dangling. Defaults to every row.

falseint

src

The source of the snapshot: a directory, or an object-store URL (s3://, gs://, azblob://). Local paths are relative to the test file.

truestring

dataset rds_snapshot​

dataset.rds_snapshot attributes​

Name and descriptionRequiredValue

batch

Maximum number of rows written per statement. Defaults to 1000.

falseint

exclude

Skip the dataset tables matching the glob patterns.

false

List of strings

include

Load only the dataset tables matching the glob patterns (orders, public.*).

false

List of strings

sample

Sample each table: load its first rows in the snapshot, up to this number, and the rows of the other loaded tables they reference, so no foreign key is left dangling. Defaults to every row.

falseint

src

The source of the snapshot: a directory, or an object-store URL (s3://, gs://, azblob://). Local paths are relative to the test file.

truestring

test migrate​

The test "migrate" "name" block describes a migrate test case.

test "migrate" "20240613061102" {
migrate {
to = "20240613061046"
}
exec {
sql = "INSERT INTO users (name) VALUES ('Ada Lovelace')"
}
migrate {
to = "20240613061102"
}
exec {
sql = "SELECT first_name,last_name FROM users"
output = "Ada, Lovelace"
}
}

test.migrate attributes​

NameRequiredValue
skipfalsebool

test.migrate blocks​

test.assert​

The assert block executes an SQL statement and expects a single-row, single-column result with a true value.

test.assert attributes​
NameRequiredValue
error_messagefalsestring
sqltruestring
test.assert constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.catch​

The catch block executes one or more SQL statements and expects an error to occur.

test.catch attributes​
NameRequiredValue
errorfalsestring
sqltruestring
test.catch constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.cleanup​

The cleanup block registers a command to be called when the test case is completed.

cleanup {
sql = "SELECT pg_catalog.set_config('search_path', '', false)"
}
test.cleanup attributes​
NameRequiredValue
sqltruestring
test.cleanup constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.dataset​

The dataset block loads a dataset registered by a top-level dataset block into the test database, at the point of the test case it appears in.

dataset {
use = dataset.rds_snapshot.prod
}
test.dataset attributes​
NameRequiredValue
usetrue

Object reference to dataset

test.dataset constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.exec​

The exec block executes one or more SQL statements and expects all of them to succeed. If output or match is defined, the output of the SQL statement is compared to the expected value.

test.exec attributes​
NameRequiredValue
formatfalse

enum (csv, table)

matchfalsestring
outputfalsestring
sqltruestring
test.exec constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.external​

The external allows executing external programs to insert data or run assertions on the dev-database used by test case.

external {
program = [
"go", "run", "seed.go",
"--dev-url", testing.dev_url,
]
}
test.external attributes​
NameRequiredValue
matchfalsestring
outputfalsestring
programtrue

List of strings

working_dirfalsestring
test.external constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.log​

The log block logs a message to the test output.

test.log attributes​
NameRequiredValue
messagetruestring
test.log constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.migrate​

test.migrate attributes​
NameRequiredValue
totruestring
test.migrate constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.script.exec​

test.script.exec attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.exec blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.exec constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.loop​

test.script.loop attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.loop blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.loop constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.query​

test.script.query attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.query blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.query constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test plan​

The test "plan" "name" block describes a schema plan test case.

test "plan" "20240613061102" {
schema {
url = "atlas://repo?version=20240613061046"
}
exec {
sql = "INSERT INTO users (name) VALUES ('Ada Lovelace')"
}
apply {
url = "file://name.plan.hcl"
}
exec {
sql = "SELECT first_name,last_name FROM users"
output = "Ada, Lovelace"
}
}

test.plan attributes​

NameRequiredValue
skipfalsebool

test.plan blocks​

test.apply​

test.apply attributes​
NameRequiredValue
urltruestring
test.apply constraints​
ConstraintValue
Requiredtrue
Require Namefalse

test.assert​

The assert block executes an SQL statement and expects a single-row, single-column result with a true value.

test.assert attributes​
NameRequiredValue
error_messagefalsestring
sqltruestring
test.assert constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.catch​

The catch block executes one or more SQL statements and expects an error to occur.

test.catch attributes​
NameRequiredValue
errorfalsestring
sqltruestring
test.catch constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.cleanup​

The cleanup block registers a command to be called when the test case is completed.

cleanup {
sql = "SELECT pg_catalog.set_config('search_path', '', false)"
}
test.cleanup attributes​
NameRequiredValue
sqltruestring
test.cleanup constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.dataset​

The dataset block loads a dataset registered by a top-level dataset block into the test database, at the point of the test case it appears in.

dataset {
use = dataset.rds_snapshot.prod
}
test.dataset attributes​
NameRequiredValue
usetrue

Object reference to dataset

test.dataset constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.exec​

The exec block executes one or more SQL statements and expects all of them to succeed. If output or match is defined, the output of the SQL statement is compared to the expected value.

test.exec attributes​
NameRequiredValue
formatfalse

enum (csv, table)

matchfalsestring
outputfalsestring
sqltruestring
test.exec constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.external​

The external allows executing external programs to insert data or run assertions on the dev-database used by test case.

external {
program = [
"go", "run", "seed.go",
"--dev-url", testing.dev_url,
]
}
test.external attributes​
NameRequiredValue
matchfalsestring
outputfalsestring
programtrue

List of strings

working_dirfalsestring
test.external constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.log​

The log block logs a message to the test output.

test.log attributes​
NameRequiredValue
messagetruestring
test.log constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.schema​

test.schema attributes​
NameRequiredValue
urltruestring
test.schema constraints​
ConstraintValue
Requiredtrue
Require Namefalse

test.script.exec​

test.script.exec attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.exec blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.exec constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.loop​

test.script.loop attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.loop blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.loop constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.query​

test.script.query attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.query blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.query constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test schema​

The test "schema" "name" block describes a schema test case.

test "schema" "postal" {
parallel = true
exec {
sql = "SELECT '12345'::us_postal_code"
}
catch {
sql = "SELECT 'hello'::us_postal_code"
}
}

test.schema attributes​

NameRequiredValue
parallelfalsebool
skipfalsebool

test.schema blocks​

test.assert​

The assert block executes an SQL statement and expects a single-row, single-column result with a true value.

test.assert attributes​
NameRequiredValue
error_messagefalsestring
sqltruestring
test.assert constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.catch​

The catch block executes one or more SQL statements and expects an error to occur.

test.catch attributes​
NameRequiredValue
errorfalsestring
sqltruestring
test.catch constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.cleanup​

The cleanup block registers a command to be called when the test case is completed.

cleanup {
sql = "SELECT pg_catalog.set_config('search_path', '', false)"
}
test.cleanup attributes​
NameRequiredValue
sqltruestring
test.cleanup constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.dataset​

The dataset block loads a dataset registered by a top-level dataset block into the test database, at the point of the test case it appears in.

dataset {
use = dataset.rds_snapshot.prod
}
test.dataset attributes​
NameRequiredValue
usetrue

Object reference to dataset

test.dataset constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.exec​

The exec block executes one or more SQL statements and expects all of them to succeed. If output or match is defined, the output of the SQL statement is compared to the expected value.

test.exec attributes​
NameRequiredValue
formatfalse

enum (csv, table)

matchfalsestring
outputfalsestring
sqltruestring
test.exec constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.external​

The external allows executing external programs to insert data or run assertions on the dev-database used by test case.

external {
program = [
"go", "run", "seed.go",
"--dev-url", testing.dev_url,
]
}
test.external attributes​
NameRequiredValue
matchfalsestring
outputfalsestring
programtrue

List of strings

working_dirfalsestring
test.external constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.log​

The log block logs a message to the test output.

test.log attributes​
NameRequiredValue
messagetruestring
test.log constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.script.exec​

test.script.exec attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.exec blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.exec constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.loop​

test.script.loop attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.loop blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.loop constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.query​

test.script.query attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.query blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.query constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test script​

The test "script" "name" block describes a script test case. The optional schema block sets up the schema the script expects and must be defined before any other block.

test "script" "vip_backfill" {
schema {
url = "file://schema.hcl"
}
exec {
sql = "INSERT INTO users (id, vip, tier) VALUES (1, true, NULL)"
}
script "exec" {
file = "vip_backfill.script.hcl"
}
assert {
sql = "SELECT count(*) = 0 FROM users WHERE vip AND tier IS NULL"
}
}

test.script attributes​

NameRequiredValue
skipfalsebool

test.script blocks​

test.assert​

The assert block executes an SQL statement and expects a single-row, single-column result with a true value.

test.assert attributes​
NameRequiredValue
error_messagefalsestring
sqltruestring
test.assert constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.catch​

The catch block executes one or more SQL statements and expects an error to occur.

test.catch attributes​
NameRequiredValue
errorfalsestring
sqltruestring
test.catch constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.cleanup​

The cleanup block registers a command to be called when the test case is completed.

cleanup {
sql = "SELECT pg_catalog.set_config('search_path', '', false)"
}
test.cleanup attributes​
NameRequiredValue
sqltruestring
test.cleanup constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.dataset​

The dataset block loads a dataset registered by a top-level dataset block into the test database, at the point of the test case it appears in.

dataset {
use = dataset.rds_snapshot.prod
}
test.dataset attributes​
NameRequiredValue
usetrue

Object reference to dataset

test.dataset constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.exec​

The exec block executes one or more SQL statements and expects all of them to succeed. If output or match is defined, the output of the SQL statement is compared to the expected value.

test.exec attributes​
NameRequiredValue
formatfalse

enum (csv, table)

matchfalsestring
outputfalsestring
sqltruestring
test.exec constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.external​

The external allows executing external programs to insert data or run assertions on the dev-database used by test case.

external {
program = [
"go", "run", "seed.go",
"--dev-url", testing.dev_url,
]
}
test.external attributes​
NameRequiredValue
matchfalsestring
outputfalsestring
programtrue

List of strings

working_dirfalsestring
test.external constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

test.log​

The log block logs a message to the test output.

test.log attributes​
NameRequiredValue
messagetruestring
test.log constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

test.schema​

test.schema attributes​
NameRequiredValue
urltruestring

test.script.exec​

test.script.exec attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.exec blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.exec constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.loop​

test.script.loop attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.loop blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.loop constraints​
ConstraintValue
Requiredfalse
Repeatabletrue

test.script.query​

test.script.query attributes​
NameRequiredValue
errorfalsestring
filetruestring
matchfalsestring
outputfalsestring
runfalsestring
varsfalsemap
test.script.query blocks​

test.script.as​

test.script.as attributes​
NameRequiredValue
passwordfalsestring
rolefalsestring
userfalsestring
test.script.as constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[role, user]
One of required sets[role, user]
test.script.query constraints​
ConstraintValue
Requiredfalse
Repeatabletrue