@@ -32,6 +32,10 @@ impl IPFS {
32
32
pub fn cat ( & self , path : String ) -> String {
33
33
return self . call ( "cat" , vec ! [ path] ) ;
34
34
}
35
+
36
+ pub fn ls ( & self , path : String ) -> Vec < ( String , u32 , String ) > {
37
+ return vec ! [ ( "" . to_string( ) , 0 , "" . to_string( ) ) ] ;
38
+ }
35
39
}
36
40
37
41
@@ -45,4 +49,19 @@ mod tests {
45
49
let server = IPFS :: new ( "localhost" . to_string ( ) , 5001 ) ;
46
50
assert_eq ! ( "This is a test" , server. cat( "/ipfs/QmR6XorNYAywK4q1dRiRN1gmvfLcx3ccBv68iGtAqon9tt" . to_string( ) ) . trim_right_matches( '\n' ) ) ;
47
51
}
52
+
53
+ #[ test]
54
+ fn ls_returns_vec_of_correct_values ( ) {
55
+ let server = IPFS :: new ( "localhost" . to_string ( ) , 5001 ) ;
56
+ // Use the ipfs.io website within IPFS as test
57
+ let response = server. ls ( "/ipfs/QmeYYwD4y4DgVVdAzhT7wW5vrvmbKPQj8wcV2pAzjbj886" . to_string ( ) ) ;
58
+ let expect = vec ! [ ( "QmTkQCrspeQDEiFBvphH3ULHYNWr3aXpymGiyjMrrUimtZ" . to_string( ) , 1717422 , "/blog" . to_string( ) ) ,
59
+ ( "Qma4JRMJgwjBhsaBkEGXh682zphSoNi67k7pgGxkqTouiK" . to_string( ) , 131161 , "/docs" . to_string( ) ) ,
60
+ ( "QmSXujSW6xykhU5wECQRrSW83YRjz8M8t93mfKddKm9ncL" . to_string( ) , 11894 , "index.html" . to_string( ) ) ,
61
+ ( "QmNXFHU3KzhzXN9pZ5Bdghk3LYGj58Xzi7WvMVVoykdLxA" . to_string( ) , 136279 , "/media" . to_string( ) ) ,
62
+ ( "QmSEBfiu7BmQkoHuBPAjs9tHqvM61NiKfFfRJR4UnTrorx" . to_string( ) , 6223432 , "/styles" . to_string( ) ) ] ;
63
+ for ( asked, gotten) in response. iter ( ) . zip ( & expect) {
64
+ assert_eq ! ( asked, gotten) ;
65
+ }
66
+ }
48
67
}
0 commit comments