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
//! Shared test support for the integration suites.
//!
//! Every integration file (`packages`, `services`, `network`, `firewall`)
//! drives the same `fez-fake-bridge` binary and repeats the same scaffolding:
//! point fez at the fake via `FEZ_BRIDGE`, silence the audit sink so tests do
//! not depend on a journal socket, and (for mutation tests) capture the
//! append-only audit log from a unique temp file. This module centralizes that
//! scaffolding so the per-suite files only express what is unique to them.
//!
//! Included via `mod common;` in each integration file. Cargo compiles every
//! file under `tests/` as its own crate, so each suite pulls in only the items
//! it references; `#![allow(dead_code)]` keeps the unused-in-this-crate items
//! from tripping warnings.
use Command as AssertCommand;
use Value;
/// Columns of a `PackageList` envelope, in wire order.
///
/// The `packages list` JSON states its column names once and emits items as
/// positional rows; several tests assert that exact header, so it lives here as
/// a single source of truth.
pub const PKG_COLUMNS: &str =
"\"columns\":[\"name\",\"evr\",\"arch\",\"repo_id\",\"install_size\",\"summary\"]";
/// A bare `fez` command with no bridge wired up.
///
/// For tests that exercise CLI surface only (help, version, `describe`,
/// `guide`, completions) and never open a bridge channel, so leaving
/// `FEZ_BRIDGE` unset is fine.
/// A `fez` command wired to the fake bridge.
///
/// Sets `FEZ_BRIDGE` to the `fez-fake-bridge` test binary so the command talks
/// to the in-repo fake instead of a real `cockpit-bridge`. The audit sink is
/// left at its default; tests that must not touch the journal should use
/// [`fez_fake_quiet`] or chain `.env("FEZ_AUDIT", "off")` themselves.
/// A [`fez_fake`] command with the audit sink disabled.
///
/// Adds `FEZ_AUDIT=off` so the run does not depend on a journal socket being
/// present. Use for read-only assertions and any mutation test that does not
/// inspect the audit log.
/// A `fez` command wired to the fake bridge with dnf5daemon forced absent, so
/// the PackageKit fallback backend is exercised.
///
/// Inherits [`fez_fake_quiet`]'s bridge wiring and disabled audit sink, and adds
/// `FEZ_FAKE_NO_DNF5` so `open_session` returns ServiceUnknown and fez falls
/// back to PackageKit (the RHEL 10 path).
/// A scratch audit-log file that cleans itself up on drop.
///
/// Wraps a process-unique temp path: the file is removed on construction (in
/// case a prior run leaked it) and again when the guard drops, so a panic
/// mid-test never leaves a stray `.jsonl` behind. Pass [`AuditLog::env_value`]
/// to `FEZ_AUDIT`, run the command, then read parsed records with
/// [`AuditLog::records`].