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 {
40
40
41
41
#[ cfg( test) ]
42
42
mod tests {
43
- use mithril_common:: { entities :: Certificate , test:: crypto_helper:: setup_certificate_chain} ;
43
+ use mithril_common:: test:: crypto_helper:: setup_certificate_chain;
44
44
use mithril_persistence:: sqlite:: ConnectionExtensions ;
45
45
46
46
use crate :: database:: test_helper:: main_db_connection;
@@ -67,9 +67,7 @@ mod tests {
67
67
#[ test]
68
68
fn test_insert_many_certificates_records ( ) {
69
69
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 ( ) ;
73
71
74
72
let connection = main_db_connection ( ) . unwrap ( ) ;
75
73
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ impl Query for InsertOrReplaceCertificateRecordQuery {
38
38
mod tests {
39
39
use std:: collections:: HashMap ;
40
40
41
- use mithril_common:: entities:: { Certificate , Epoch } ;
41
+ use mithril_common:: entities:: Epoch ;
42
42
use mithril_common:: test:: { crypto_helper:: setup_certificate_chain, double:: fake_data} ;
43
43
use mithril_persistence:: sqlite:: ConnectionExtensions ;
44
44
@@ -50,9 +50,7 @@ mod tests {
50
50
#[ test]
51
51
fn test_insert_many_certificates_records_in_empty_db ( ) {
52
52
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 ( ) ;
56
54
57
55
let connection = main_db_connection ( ) . unwrap ( ) ;
58
56
Original file line number Diff line number Diff line change @@ -123,9 +123,11 @@ impl DerefMut for CertificateChainFixture {
123
123
}
124
124
}
125
125
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 ( )
129
131
}
130
132
}
131
133
You can’t perform that action at this time.
0 commit comments