File tree Expand file tree Collapse file tree 3 files changed +9
-11
lines changed
mithril-aggregator/src/database/query/certificate
mithril-common/src/test/builder Expand file tree Collapse file tree 3 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ impl Query for InsertCertificateRecordQuery {
4040
4141#[ cfg( test) ]
4242mod tests {
43- use mithril_common:: { entities :: Certificate , test:: crypto_helper:: setup_certificate_chain} ;
43+ use mithril_common:: test:: crypto_helper:: setup_certificate_chain;
4444 use mithril_persistence:: sqlite:: ConnectionExtensions ;
4545
4646 use crate :: database:: test_helper:: main_db_connection;
@@ -67,9 +67,7 @@ mod tests {
6767 #[ test]
6868 fn test_insert_many_certificates_records ( ) {
6969 let certificates = setup_certificate_chain ( 5 , 2 ) ;
70- let certificates: Vec < Certificate > = certificates. into ( ) ;
71- let certificates_records: Vec < CertificateRecord > =
72- certificates. into_iter ( ) . map ( |c| c. try_into ( ) . unwrap ( ) ) . collect ( ) ;
70+ let certificates_records: Vec < CertificateRecord > = certificates. try_into ( ) . unwrap ( ) ;
7371
7472 let connection = main_db_connection ( ) . unwrap ( ) ;
7573
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ impl Query for InsertOrReplaceCertificateRecordQuery {
3838mod tests {
3939 use std:: collections:: HashMap ;
4040
41- use mithril_common:: entities:: { Certificate , Epoch } ;
41+ use mithril_common:: entities:: Epoch ;
4242 use mithril_common:: test:: { crypto_helper:: setup_certificate_chain, double:: fake_data} ;
4343 use mithril_persistence:: sqlite:: ConnectionExtensions ;
4444
@@ -50,9 +50,7 @@ mod tests {
5050 #[ test]
5151 fn test_insert_many_certificates_records_in_empty_db ( ) {
5252 let certificates = setup_certificate_chain ( 5 , 2 ) ;
53- let certificates: Vec < Certificate > = certificates. into ( ) ;
54- let certificates_records: Vec < CertificateRecord > =
55- certificates. into_iter ( ) . map ( |c| c. try_into ( ) . unwrap ( ) ) . collect ( ) ;
53+ let certificates_records: Vec < CertificateRecord > = certificates. try_into ( ) . unwrap ( ) ;
5654
5755 let connection = main_db_connection ( ) . unwrap ( ) ;
5856
Original file line number Diff line number Diff line change @@ -123,9 +123,11 @@ impl DerefMut for CertificateChainFixture {
123123 }
124124}
125125
126- impl < C : From < Certificate > > From < CertificateChainFixture > for Vec < C > {
127- fn from ( fixture : CertificateChainFixture ) -> Self {
128- fixture. certificates_chained . into_iter ( ) . map ( C :: from) . collect ( )
126+ impl < C : TryFrom < Certificate > > TryFrom < CertificateChainFixture > for Vec < C > {
127+ type Error = C :: Error ;
128+
129+ fn try_from ( fixture : CertificateChainFixture ) -> Result < Self , Self :: Error > {
130+ fixture. certificates_chained . into_iter ( ) . map ( C :: try_from) . collect ( )
129131 }
130132}
131133
You can’t perform that action at this time.
0 commit comments