faucet-cli 1.13.0

Config-driven CLI runner for faucet-stream pipelines (YAML / JSON, Meltano-style)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
//! `faucet schema` — print the JSON Schema for a connector's config.

use crate::cli::{SchemaArgs, SchemaTarget};
use crate::error::{CliError, CliResult};
use crate::registry::{sink_schema, source_schema};
use crate::transforms::transform_schema;

/// Every valid `faucet schema <target>` keyword compiled into this binary, in a
/// stable order. Feature-gated targets appear only when their feature is on, so
/// the listing matches what this build can actually emit. `source`, `sink`, and
/// `transform` additionally take a connector/transform NAME argument.
pub fn schema_targets() -> Vec<&'static str> {
    let mut targets = vec![
        "config",
        "source",
        "sink",
        "transform",
        "dlq",
        "mirror",
        "backfill",
        "partition",
        "execution",
        "resilience",
        "sla",
        "profiling",
        "verify",
        "rollback",
    ];
    #[cfg(feature = "quality")]
    targets.push("quality");
    #[cfg(feature = "contract")]
    targets.push("contract");
    #[cfg(feature = "policy")]
    targets.push("policy");
    #[cfg(feature = "masking")]
    targets.push("masking");
    targets.push("test");
    targets.push("source-template");
    targets.push("sink-template");
    #[cfg(feature = "templates")]
    targets.push("template-test");
    #[cfg(feature = "templates-sync")]
    targets.push("templates-sync");
    targets.push("secrets");
    #[cfg(feature = "schedule")]
    targets.push("schedule");
    #[cfg(feature = "lineage")]
    targets.push("lineage");
    #[cfg(feature = "triggers")]
    targets.push("triggers");
    #[cfg(feature = "notify")]
    targets.push("notifications");
    #[cfg(feature = "catalog")]
    targets.push("catalog");
    #[cfg(feature = "catalog")]
    targets.push("local-outputs");
    targets.push("params");
    targets
}

/// A config block the web console's submit form can add beside the source,
/// sink, and transforms: its name, a one-line description, and whether it
/// lives under `pipeline:` or at the top level of the config.
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
pub struct PipelineBlock {
    pub name: &'static str,
    pub description: &'static str,
    pub placement: &'static str,
}

/// Every [`PipelineBlock`] compiled into this binary, in form order.
pub fn pipeline_blocks() -> Vec<PipelineBlock> {
    let block = |name, description, placement| PipelineBlock {
        name,
        description,
        placement,
    };
    let mut blocks = vec![
        block(
            "state",
            "Where bookmarks are kept so the next run resumes where this one stopped",
            "pipeline",
        ),
        block(
            "dlq",
            "A sink for records that fail to write or are quarantined",
            "pipeline",
        ),
        block(
            "delivery",
            "At-least-once, or exactly-once where the source and sink support it",
            "top",
        ),
        block(
            "resilience",
            "Retries, circuit breaker, and poison-record handling for sink writes",
            "top",
        ),
        block(
            "sla",
            "Freshness and volume expectations checked after every run",
            "top",
        ),
        block(
            "profiling",
            "Learn each column's profile per run and flag statistically significant drift — no thresholds",
            "top",
        ),
        block(
            "verify",
            "Compare the destination to the source by content after every run; repair differences",
            "top",
        ),
        #[cfg(feature = "policy")]
        block(
            "policy",
            "Data-flow policy: label columns and say which sinks they may reach",
            "top",
        ),
        block(
            "rollback",
            "Make every run undoable with `faucet rollback` (journal, kept previous table, run-id column)",
            "top",
        ),
    ];
    #[cfg(feature = "quality")]
    blocks.push(block(
        "quality",
        "Per-record and per-batch data-quality checks",
        "pipeline",
    ));
    #[cfg(feature = "contract")]
    blocks.push(block(
        "contract",
        "A versioned promise about the output's fields and types",
        "pipeline",
    ));
    #[cfg(feature = "masking")]
    blocks.push(block(
        "masking",
        "Detect and mask PII before it reaches any sink",
        "pipeline",
    ));
    blocks.push(block(
        "schema",
        "What to do when incoming records drift from the destination schema",
        "pipeline",
    ));
    blocks
}

fn to_schema_value(s: faucet_core::schemars::Schema) -> serde_json::Value {
    serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
}

/// The `state:` block as a discriminated union over the compiled backends, so
/// a form can offer each backend's own fields (the Rust type keeps `config`
/// untyped because the backends are feature-gated).
fn state_block_schema() -> serde_json::Value {
    use serde_json::json;
    let variant = |kind: &str, config: serde_json::Value| {
        json!({
            "type": "object",
            "properties": { "type": { "const": kind }, "config": config },
            "required": ["type"],
        })
    };
    let mut variants = vec![
        variant(
            "file",
            json!({
                "type": "object",
                "properties": { "path": { "type": "string", "description": "Directory holding one JSON file per bookmark" } },
                "required": ["path"],
            }),
        ),
        variant(
            "memory",
            json!({ "type": "object", "properties": {}, "description": "Kept in memory only; lost when the run ends" }),
        ),
    ];
    #[cfg(feature = "state-redis")]
    variants.push(variant(
        "redis",
        json!({
            "type": "object",
            "properties": {
                "url": { "type": "string", "description": "Redis connection URL" },
                "namespace": { "type": "string", "default": "faucet", "description": "Key prefix" },
            },
            "required": ["url"],
        }),
    ));
    #[cfg(feature = "state-postgres")]
    variants.push(variant(
        "postgres",
        json!({
            "type": "object",
            "properties": {
                "url": { "type": "string", "description": "PostgreSQL connection URL" },
                "table": { "type": "string", "default": "faucet_state", "description": "Bookmark table" },
                "ensure_table": { "type": "boolean", "description": "Create the table if it does not exist" },
                "max_connections": { "type": "integer", "description": "Connection pool size" },
            },
            "required": ["url"],
        }),
    ));
    json!({ "title": "State store", "oneOf": variants })
}

/// The JSON Schema for one [`PipelineBlock`], or `None` for an unknown or
/// uncompiled block.
pub fn block_schema(name: &str) -> Option<serde_json::Value> {
    Some(match name {
        "state" => state_block_schema(),
        "dlq" => to_schema_value(faucet_core::schema_for!(crate::config::DlqSpec)),
        "delivery" => to_schema_value(faucet_core::schema_for!(faucet_core::DeliveryMode)),
        "resilience" => to_schema_value(faucet_core::schema_for!(crate::config::ResilienceSpec)),
        "sla" => to_schema_value(faucet_core::schema_for!(crate::sla::SlaSpec)),
        "profiling" => to_schema_value(faucet_core::schema_for!(faucet_core::ProfilingSpec)),
        #[cfg(feature = "policy")]
        "policy" => to_schema_value(faucet_core::schema_for!(faucet_core::PolicySpec)),
        "verify" => to_schema_value(faucet_core::schema_for!(crate::verify::VerifySpec)),
        "rollback" => to_schema_value(faucet_core::schema_for!(crate::rollback::RollbackSpec)),
        "schema" => to_schema_value(faucet_core::schema_for!(faucet_core::SchemaDriftSpec)),
        #[cfg(feature = "quality")]
        "quality" => to_schema_value(faucet_core::schema_for!(faucet_core::QualitySpec)),
        #[cfg(feature = "contract")]
        "contract" => to_schema_value(faucet_core::schema_for!(faucet_core::ContractSpec)),
        #[cfg(feature = "masking")]
        "masking" => to_schema_value(faucet_core::schema_for!(faucet_core::MaskingSpec)),
        _ => return None,
    })
}

/// Execute the `schema` subcommand.
pub async fn run(args: SchemaArgs) -> CliResult<()> {
    if args.list {
        println!("Valid `faucet schema <target>` targets:");
        for t in schema_targets() {
            match t {
                "source" | "sink" | "transform" => println!("  {t} <name>"),
                _ => println!("  {t}"),
            }
        }
        return Ok(());
    }
    let target = args.target.ok_or_else(|| {
        CliError::Config(
            "no schema target given — pass one (e.g. `faucet schema source rest`) or \
             `faucet schema --list` to see them all"
                .to_owned(),
        )
    })?;
    let schema = match target {
        SchemaTarget::Config => crate::schema_compose::config_schema(),
        SchemaTarget::Source { name } => source_schema(&name)?,
        SchemaTarget::Sink { name } => sink_schema(&name)?,
        SchemaTarget::Transform { name } => transform_schema(&name)?,
        SchemaTarget::Dlq => block_schema("dlq").expect("dlq is always compiled"),
        SchemaTarget::Verify => block_schema("verify").expect("verify is always compiled"),
        SchemaTarget::Rollback => block_schema("rollback").expect("rollback is always compiled"),
        SchemaTarget::Usage => {
            let s = faucet_core::schema_for!(crate::usage::UsageSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Budget => {
            let s = faucet_core::schema_for!(faucet_core::BudgetSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Replication => {
            let s = faucet_core::schema_for!(crate::replication::spec::ReplicationSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Backfill => {
            let s = faucet_core::schema_for!(crate::backfill::BackfillSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Partition => {
            let s = faucet_core::schema_for!(crate::partition::PartitionSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Params => {
            let s = faucet_core::schema_for!(crate::params::ParamSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Execution => {
            let s = faucet_core::schema_for!(crate::config::ExecutionSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Resilience => {
            let s = faucet_core::schema_for!(crate::config::ResilienceSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Sla => {
            let s = faucet_core::schema_for!(crate::sla::SlaSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Profiling => {
            let s = faucet_core::schema_for!(faucet_core::ProfilingSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "policy")]
        SchemaTarget::Policy => {
            let s = faucet_core::schema_for!(faucet_core::PolicySpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "quality")]
        SchemaTarget::Quality => {
            let quality_schema = faucet_core::schema_for!(faucet_core::QualitySpec);
            serde_json::to_value(quality_schema)
                .unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "contract")]
        SchemaTarget::Contract => {
            let contract_schema = faucet_core::schema_for!(faucet_core::ContractSpec);
            serde_json::to_value(contract_schema)
                .unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "masking")]
        SchemaTarget::Masking => {
            let masking_schema = faucet_core::schema_for!(faucet_core::MaskingSpec);
            serde_json::to_value(masking_schema)
                .unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "schedule")]
        SchemaTarget::Schedule => {
            let s = faucet_core::schema_for!(crate::schedule::spec::ScheduleSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "lineage")]
        SchemaTarget::Lineage => lineage_schema(),
        #[cfg(feature = "triggers")]
        SchemaTarget::Triggers => {
            let s = faucet_core::schema_for!(crate::serve::triggers::spec::TriggersFile);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::SourceTemplate => {
            serde_json::to_value(faucet_core::schema_for!(crate::hub::spec::SourceTemplate))
                .expect("schema serialization")
        }
        SchemaTarget::SinkTemplate => {
            serde_json::to_value(faucet_core::schema_for!(crate::hub::spec::SinkTemplate))
                .expect("schema serialization")
        }
        SchemaTarget::Deployment => serde_json::to_value(faucet_core::schema_for!(
            crate::hub::spec::DeploymentTemplate
        ))
        .expect("schema serialization"),
        SchemaTarget::Test => {
            let s = faucet_core::schema_for!(crate::pipeline_test::spec::TestSpecFile);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "templates")]
        SchemaTarget::TemplateTest => serde_json::to_value(faucet_core::schema_for!(
            crate::templates::suite::spec::SuiteFile
        ))
        .expect("schema serialization"),
        #[cfg(feature = "templates-sync")]
        SchemaTarget::TemplatesSync => serde_json::to_value(faucet_core::schema_for!(
            crate::templates::sync::spec::SyncFile
        ))
        .expect("schema serialization"),
        #[cfg(feature = "notify")]
        SchemaTarget::Notifications => {
            // The `notifications:` block is a list; emit the per-rule schema.
            let s = faucet_core::schema_for!(crate::notify::NotificationSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "catalog")]
        SchemaTarget::Catalog => {
            let s = faucet_core::schema_for!(crate::catalog::CatalogSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        #[cfg(feature = "catalog")]
        SchemaTarget::LocalOutputs => {
            let s = faucet_core::schema_for!(crate::local_outputs::LocalOutputsSpec);
            serde_json::to_value(s).unwrap_or_else(|_| serde_json::json!({"type": "object"}))
        }
        SchemaTarget::Secrets => serde_json::json!({
            "title": "Secrets-manager interpolation grammar",
            "schemes": {
                "vault":    { "syntax": "${vault:<path>[#field]}", "auth": ["VAULT_ADDR", "VAULT_TOKEN", "VAULT_NAMESPACE (optional)"] },
                "aws-sm":   { "syntax": "${aws-sm:<name-or-ARN>[#field]}", "auth": ["aws-config default credential chain"] },
                "gcp-sm":   { "syntax": "${gcp-sm:projects/<p>/secrets/<s>/versions/<v>}", "auth": ["Application Default Credentials"] },
                "azure-kv": { "syntax": "${azure-kv:<vault>/<secret>[/<version>]}", "auth": ["AZURE_* env / managed identity / az login"] }
            },
            "notes": [
                "#field parses the secret as JSON and extracts one key (vault, aws-sm).",
                "Resolved at config load; fetched concurrently and de-duplicated; never persisted.",
                "Build with --features secrets (or per-backend secrets-vault / secrets-aws-sm / ...)."
            ]
        }),
    };
    let body = serde_json::to_string_pretty(&schema).unwrap_or_else(|_| schema.to_string());
    println!("{body}");
    Ok(())
}

/// JSON Schema for the `lineage:` config block (`faucet schema lineage`).
#[cfg(feature = "lineage")]
pub fn lineage_schema() -> serde_json::Value {
    serde_json::to_value(faucet_lineage::schemars_schema())
        .unwrap_or_else(|_| serde_json::json!({"type": "object"}))
}

#[cfg(test)]
mod tests {
    use crate::cli::{SchemaArgs, SchemaTarget};

    #[test]
    fn every_pipeline_block_has_a_schema_and_a_known_placement() {
        let blocks = super::pipeline_blocks();
        assert!(blocks.iter().any(|b| b.name == "dlq"));
        for b in &blocks {
            assert!(matches!(b.placement, "pipeline" | "top"), "{}", b.name);
            assert!(!b.description.is_empty(), "{}", b.name);
            assert!(super::block_schema(b.name).is_some(), "{}", b.name);
        }
        assert!(super::block_schema("nope").is_none());
    }

    #[test]
    fn state_block_offers_each_backend_with_its_own_fields() {
        let v = super::block_schema("state").unwrap();
        let variants = v["oneOf"].as_array().unwrap();
        let kinds: Vec<&str> = variants
            .iter()
            .map(|v| v["properties"]["type"]["const"].as_str().unwrap())
            .collect();
        assert_eq!(&kinds[..2], ["file", "memory"]);
        assert_eq!(
            variants[0]["properties"]["config"]["required"],
            serde_json::json!(["path"])
        );
        let mut offered = kinds.clone();
        offered.sort_unstable();
        let mut compiled = crate::state::available_state_kinds();
        compiled.sort_unstable();
        assert_eq!(
            offered, compiled,
            "the form must offer exactly the compiled backends"
        );
    }

    #[cfg(feature = "lineage")]
    #[test]
    fn schema_lineage_returns_object_schema() {
        let v = super::lineage_schema();
        assert_eq!(v["type"], "object");
        assert!(v["properties"].get("transport").is_some());
        assert!(v["properties"].get("namespace").is_some());
    }

    #[test]
    fn schema_targets_includes_known_targets() {
        let targets = super::schema_targets();
        for known in ["config", "source", "sink", "dlq", "params"] {
            assert!(
                targets.contains(&known),
                "missing target {known}: {targets:?}"
            );
        }
        // No duplicates.
        let mut sorted = targets.clone();
        sorted.sort_unstable();
        sorted.dedup();
        assert_eq!(
            sorted.len(),
            targets.len(),
            "duplicate targets: {targets:?}"
        );
    }

    #[tokio::test]
    async fn schema_list_flag_returns_ok() {
        let r = super::run(SchemaArgs {
            target: None,
            list: true,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
    }

    #[tokio::test]
    async fn schema_no_target_without_list_errors() {
        let r = super::run(SchemaArgs {
            target: None,
            list: false,
        })
        .await;
        assert!(
            r.is_err(),
            "expected an error when neither target nor --list given"
        );
    }

    #[tokio::test]
    async fn schema_replication_target_ok() {
        // Covers the `SchemaTarget::Replication` arm — it serializes the
        // ReplicationSpec JSON Schema to stdout and returns Ok.
        let r = super::run(SchemaArgs {
            target: Some(SchemaTarget::Replication),
            list: false,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
    }

    #[tokio::test]
    async fn schema_execution_target_ok() {
        let r = super::run(SchemaArgs {
            target: Some(SchemaTarget::Execution),
            list: false,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
    }

    #[test]
    fn execution_schema_includes_adaptive_batch_size() {
        let schema = faucet_core::schema_for!(crate::config::ExecutionSpec);
        let value = serde_json::to_value(schema).expect("execution schema serializes");
        assert!(value["properties"].get("adaptive_batch_size").is_some());
    }

    #[tokio::test]
    async fn schema_sla_target_ok() {
        let r = super::run(SchemaArgs {
            target: Some(SchemaTarget::Sla),
            list: false,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
    }

    #[tokio::test]
    async fn schema_profiling_target_ok() {
        let r = super::run(SchemaArgs {
            target: Some(SchemaTarget::Profiling),
            list: false,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
        let s = serde_json::to_string(&super::block_schema("profiling").unwrap()).unwrap();
        assert!(s.contains("on_drift") && s.contains("min_history"), "{s}");
        assert!(
            super::pipeline_blocks()
                .iter()
                .any(|b| b.name == "profiling")
        );
    }

    #[test]
    fn sla_schema_exposes_the_three_checks() {
        let schema = faucet_core::schema_for!(crate::sla::SlaSpec);
        let out = serde_json::to_string(&schema).expect("sla schema serializes");
        assert!(out.contains("max_staleness_secs"), "{out}");
        assert!(out.contains("min_rows_per_run"), "{out}");
        assert!(out.contains("volume_anomaly"), "{out}");
    }

    #[tokio::test]
    async fn schema_resilience_target_ok() {
        let r = super::run(SchemaArgs {
            target: Some(SchemaTarget::Resilience),
            list: false,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
    }

    #[test]
    fn schema_resilience_emits_json_schema() {
        // Mirrors `faucet schema resilience`: the serialized ResilienceSpec
        // schema must expose the retry `max_attempts` knob and the
        // `circuit_breaker` sub-block.
        let schema = faucet_core::schema_for!(crate::config::ResilienceSpec);
        let out = serde_json::to_string(&schema).expect("resilience schema serializes");
        assert!(out.contains("max_attempts"), "{out}");
        assert!(out.contains("circuit_breaker"), "{out}");
    }

    /// `faucet schema template-test` is the only way to discover the suite
    /// file's grammar, so the target must actually resolve to a schema rather
    /// than falling through the dispatch match.
    #[cfg(feature = "templates")]
    #[tokio::test]
    async fn schema_template_test_target_renders() {
        let r = super::run(SchemaArgs {
            target: Some(SchemaTarget::TemplateTest),
            list: false,
        })
        .await;
        assert!(r.is_ok(), "{r:?}");
        // The target must also be discoverable from `--list`.
        assert!(super::schema_targets().contains(&"template-test"));
    }

    #[tokio::test]
    async fn usage_and_budget_targets_print_their_schemas() {
        for target in [SchemaTarget::Usage, SchemaTarget::Budget] {
            let r = super::run(SchemaArgs {
                target: Some(target),
                list: false,
            })
            .await;
            assert!(r.is_ok(), "{r:?}");
        }
    }
}