Skip to content

Commit e8623b8

Browse files
committed
test(clitools): extract Assert::redact()
1 parent 603d2dc commit e8623b8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/test/clitools.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl Assert {
137137
Self { output, redactions }
138138
}
139139

140-
/// Extend the redaction rules used in the currrent assertion with new values.
140+
/// Extends the redaction rules used in the current assertion with new values.
141141
pub fn extend_redactions(
142142
&mut self,
143143
vars: impl IntoIterator<Item = (&'static str, impl Into<RedactedValue>)>,
@@ -148,6 +148,7 @@ impl Assert {
148148
self
149149
}
150150

151+
/// Removes the existing redaction rules used in the current assertion.
151152
pub fn remove_redactions(&mut self, vars: impl IntoIterator<Item = &'static str>) -> &mut Self {
152153
for var in vars {
153154
self.redactions
@@ -157,6 +158,11 @@ impl Assert {
157158
self
158159
}
159160

161+
/// Performs the redaction based on the existing rules.
162+
pub fn redact(&self, input: &str) -> String {
163+
self.redactions.redact(input)
164+
}
165+
160166
/// Asserts that the command exited with an ok status.
161167
pub fn is_ok(&self) -> &Self {
162168
assert!(self.output.ok);
@@ -171,7 +177,7 @@ impl Assert {
171177

172178
/// Asserts that the command exited with the given `expected` stdout pattern.
173179
pub fn with_stdout(&self, expected: impl IntoData) -> &Self {
174-
let stdout = self.redactions.redact(&self.output.stdout);
180+
let stdout = self.redact(&self.output.stdout);
175181
assert_data_eq!(&stdout, expected);
176182
self
177183
}
@@ -187,7 +193,7 @@ impl Assert {
187193

188194
/// Asserts that the command exited with the given `expected` stderr pattern.
189195
pub fn with_stderr(&self, expected: impl IntoData) -> &Self {
190-
let stderr = self.redactions.redact(&self.output.stderr);
196+
let stderr = self.redact(&self.output.stderr);
191197
assert_data_eq!(&stderr, expected);
192198
self
193199
}

0 commit comments

Comments
 (0)