File tree Expand file tree Collapse file tree 6 files changed +10
-25
lines changed Expand file tree Collapse file tree 6 files changed +10
-25
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ impl SnapshotDownloadCommand {
59
59
let progress_output_type = if self . json {
60
60
ProgressOutputType :: JsonReporter
61
61
} else {
62
- ProgressOutputType :: TTY
62
+ ProgressOutputType :: Tty
63
63
} ;
64
64
let progress_printer = ProgressPrinter :: new ( progress_output_type, 5 ) ;
65
65
let client = ClientBuilder :: aggregator (
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ impl ConfigParameters {
24
24
}
25
25
26
26
/// Useful constructor for testing
27
+ #[ cfg( test) ]
27
28
pub fn build ( parameters : & [ ( & str , & str ) ] ) -> Self {
28
29
let parameters = parameters
29
30
. iter ( )
@@ -34,6 +35,7 @@ impl ConfigParameters {
34
35
}
35
36
36
37
/// Add or replace a parameter in the holder
38
+ #[ cfg( test) ]
37
39
pub fn add_parameter ( & mut self , name : & str , value : & str ) -> & mut Self {
38
40
let _ = self . parameters . insert ( name. to_string ( ) , value. to_string ( ) ) ;
39
41
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ impl FeedbackReceiver for IndicatifFeedbackReceiver {
35
35
download_id : _,
36
36
size,
37
37
} => {
38
- let pb = if self . output_type == ProgressOutputType :: TTY {
38
+ let pb = if self . output_type == ProgressOutputType :: Tty {
39
39
ProgressBar :: new ( size)
40
40
} else {
41
41
ProgressBar :: with_draw_target ( Some ( size) , ProgressDrawTarget :: hidden ( ) )
@@ -68,7 +68,7 @@ impl FeedbackReceiver for IndicatifFeedbackReceiver {
68
68
MithrilEvent :: CertificateChainValidationStarted {
69
69
certificate_chain_validation_id : _,
70
70
} => {
71
- let pb = if self . output_type == ProgressOutputType :: TTY {
71
+ let pb = if self . output_type == ProgressOutputType :: Tty {
72
72
ProgressBar :: new_spinner ( )
73
73
} else {
74
74
ProgressBar :: hidden ( )
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ pub enum ProgressOutputType {
14
14
/// Output to json
15
15
JsonReporter ,
16
16
/// Output to tty
17
- TTY ,
17
+ Tty ,
18
18
/// No output
19
19
Hidden ,
20
20
}
@@ -23,7 +23,7 @@ impl From<ProgressOutputType> for ProgressDrawTarget {
23
23
fn from ( value : ProgressOutputType ) -> Self {
24
24
match value {
25
25
ProgressOutputType :: JsonReporter => ProgressDrawTarget :: hidden ( ) ,
26
- ProgressOutputType :: TTY => ProgressDrawTarget :: stdout ( ) ,
26
+ ProgressOutputType :: Tty => ProgressDrawTarget :: stdout ( ) ,
27
27
ProgressOutputType :: Hidden => ProgressDrawTarget :: hidden ( ) ,
28
28
}
29
29
}
@@ -54,7 +54,7 @@ impl ProgressPrinter {
54
54
timestamp = Utc :: now( ) . to_rfc3339( ) ,
55
55
number_of_steps = self . number_of_steps,
56
56
) ,
57
- ProgressOutputType :: TTY => self
57
+ ProgressOutputType :: Tty => self
58
58
. multi_progress
59
59
. println ( format ! ( "{step_number}/{} - {text}" , self . number_of_steps) ) ?,
60
60
ProgressOutputType :: Hidden => ( ) ,
Original file line number Diff line number Diff line change @@ -67,21 +67,15 @@ mod test {
67
67
68
68
#[ test]
69
69
fn check_disk_space_error_should_return_error_if_error_is_not_error_not_enough_space ( ) {
70
- let error = SnapshotUnpackerError :: UnpackFailed {
71
- dirpath : PathBuf :: from ( "" ) ,
72
- error : anyhow:: Error :: msg ( "Some error message" ) ,
73
- } ;
70
+ let error = SnapshotUnpackerError :: UnpackDirectoryAlreadyExists ( PathBuf :: new ( ) ) ;
74
71
75
72
let error = SnapshotUtils :: check_disk_space_error ( anyhow ! ( error) )
76
73
. expect_err ( "check_disk_space_error should fail" ) ;
77
74
78
75
assert ! (
79
76
matches!(
80
77
error. downcast_ref:: <SnapshotUnpackerError >( ) ,
81
- Some ( SnapshotUnpackerError :: UnpackFailed {
82
- dirpath: _,
83
- error: _
84
- } )
78
+ Some ( SnapshotUnpackerError :: UnpackDirectoryAlreadyExists ( _) )
85
79
) ,
86
80
"Unexpected error: {:?}" ,
87
81
error
Original file line number Diff line number Diff line change @@ -38,17 +38,6 @@ pub enum SnapshotUnpackerError {
38
38
/// Cannot write in the given directory.
39
39
#[ error( "Unpack directory '{0}' is not writable." ) ]
40
40
UnpackDirectoryIsNotWritable ( PathBuf , #[ source] StdError ) ,
41
-
42
- /// Unpacking error
43
- #[ error( "Could not unpack from streamed data snapshot to directory '{dirpath}'" ) ]
44
- UnpackFailed {
45
- /// Location where the archive is to be extracted.
46
- dirpath : PathBuf ,
47
-
48
- /// Subsystem error
49
- #[ source]
50
- error : StdError ,
51
- } ,
52
41
}
53
42
54
43
impl SnapshotUnpacker {
You can’t perform that action at this time.
0 commit comments