diff options
author | David Runge <dave@sleepmap.de> | 2023-10-04 19:12:22 +0200 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2023-10-06 17:59:06 +0200 |
commit | 37e1364032d8e1592cee0c16fd726abacc6fd07c (patch) | |
tree | b2a154e3396b5c0af678a34f1b2e52a4618a7c36 | |
parent | a83799b778e8645c5ba58b3ecbf8b295c41af96f (diff) |
openpgp: Use CertBuilder::new() in doc tests to count reliably.
Adapt the doc tests of `KeyAmalgamationIter::secret()`,
`KeyAmalgamationIter::unencrypted_secret()`,
`ValidKeyAmalgamationIter::secret()` and
`ValidKeyAmalgamationIter::unencrypted_secret()` to make use of
`CertBuilder::new()` instead of `CertBuilder::general_purpose()` to be
able to test for the amount of found keys more reliably.
Signed-off-by: David Runge <dave@sleepmap.de>
-rw-r--r-- | openpgp/src/cert/amalgamation/key/iter.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/openpgp/src/cert/amalgamation/key/iter.rs b/openpgp/src/cert/amalgamation/key/iter.rs index dcc13000..10483657 100644 --- a/openpgp/src/cert/amalgamation/key/iter.rs +++ b/openpgp/src/cert/amalgamation/key/iter.rs @@ -262,11 +262,15 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> /// # use openpgp::cert::prelude::*; /// # fn main() -> Result<()> { /// # let (cert, _) = - /// # CertBuilder::general_purpose(None, Some("alice@example.org")) + /// # CertBuilder::new().set_password(Some("password".into())) /// # .generate()?; /// for ka in cert.keys().secret() { /// // Use it. /// } + /// # assert!(cert.keys().secret().count() == 1); + /// # + /// # let (cert, _) = CertBuilder::new().generate()?; + /// # assert!(cert.keys().secret().count() == 1); /// # Ok(()) /// # } /// ``` @@ -337,11 +341,11 @@ impl<'a, P, R> KeyAmalgamationIter<'a, P, R> /// # use openpgp::cert::prelude::*; /// # fn main() -> Result<()> { /// # let (cert, _) = - /// # CertBuilder::general_purpose(None, Some("alice@example.org")) - /// # .generate()?; + /// # CertBuilder::new().generate()?; /// for ka in cert.keys().unencrypted_secret() { /// // Use it. /// } + /// # assert!(cert.keys().secret().unencrypted_secret().count() == 1); /// # Ok(()) /// # } /// ``` @@ -1357,11 +1361,15 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// let p = &StandardPolicy::new(); /// /// # let (cert, _) = - /// # CertBuilder::general_purpose(None, Some("alice@example.org")) + /// # CertBuilder::new().set_password(Some("password".into())) /// # .generate()?; /// for ka in cert.keys().with_policy(p, None).secret() { /// // Use it. /// } + /// # assert!(cert.keys().with_policy(p, None).secret().count() == 1); + /// # + /// # let (cert, _) = CertBuilder::new().generate()?; + /// # assert!(cert.keys().with_policy(p, None).secret().count() == 1); /// # Ok(()) /// # } /// ``` @@ -1451,12 +1459,11 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> /// # fn main() -> Result<()> { /// let p = &StandardPolicy::new(); /// - /// # let (cert, _) = - /// # CertBuilder::general_purpose(None, Some("alice@example.org")) - /// # .generate()?; + /// # let (cert, _) = CertBuilder::new().generate()?; /// for ka in cert.keys().with_policy(p, None).unencrypted_secret() { /// // Use it. /// } + /// # assert!(cert.keys().with_policy(p, None).unencrypted_secret().count() == 1); /// # Ok(()) /// # } /// ``` |