BUCKannotatedBUCKsource51 lines · 1.9 KB · raw
1load("//build:defs.bzl", "first_party_test", "pg_major_select")
2
3# Integration tests: a throwaway Postgres from the devshell per test,
4# serving the built extension in place.
5_env = lambda m: {
6    "POSTJEVSQL_EXT": "$(location //crates/postjevsql:ext)",
7    # The server of the major the test is configured for (its
8    # `pg_major` constraint), written into .buckconfig.local by the
9    # devshell, one per major.
10    "POSTJEVSQL_PG_MAJOR": m,
11    "POSTJEVSQL_POSTGRES_BIN": read_config("postjevsql", "postgres_bin_" + m, read_config("postjevsql", "postgres_bin")),
12    # The release gates' recorded answers (tools/record-gates --send),
13    # replayed by gate_*.rs.
14    "POSTJEVSQL_FIXTURES": "$(location :fixtures)",
15}
16TEST_ENV = pg_major_select(_env)
17
18# Keyed by file name, so the location is the directory holding them.
19filegroup(
20    name = "fixtures",
21    srcs = {f.removeprefix("fixtures/"): f for f in glob(["fixtures/*.json"])},
22)
23
24TEST_DEPS = [
25    "//third-party:hickory-proto",
26    "//tests/support:support",
27    "//third-party:http",
28    "//third-party:serde_json",
29    "//third-party:tempfile",
30    "//third-party:tokio",
31    "//third-party:tokio-postgres",
32]
33
34[
35    first_party_test(
36        name = name,
37        srcs = [name + ".rs"],
38        crate_root = name + ".rs",
39        env = TEST_ENV,
40        deps = TEST_DEPS,
41    )
42    for name in ["api_key", "batching", "budget", "cache", "cancel", "canonical", "choice", "confidence", "dml", "dns", "eval", "gate_label_tree", "gate_layout_parity", "gate_ranking", "gate_unsure_band", "happy_path", "keepalive", "label_tree", "latency", "on_error", "privileges", "ratelimit", "replay", "retries", "score", "settings", "shortlist", "sidecar", "stats", "threshold"]
43]
44
45first_party_test(
46    name = "sidecar_cli",
47    srcs = ["sidecar_cli.rs"],
48    crate_root = "sidecar_cli.rs",
49    env = pg_major_select(lambda m: dict(_env(m), POSTJEVSQL_SIDECAR_CLI = "$(location //crates/postjevsql-sidecar:cli)")),
50    deps = TEST_DEPS,
51)