Skip to content

Commit 60ed7e9

Browse files
committed
ls test added and failing.
2 parents c5f5de8 + b1eb534 commit 60ed7e9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ impl IPFS {
3232
pub fn cat (&self, path: String) -> String {
3333
return self.call("cat", vec![path]);
3434
}
35+
36+
pub fn ls (&self, path: String) -> Vec<(String, u32, String)> {
37+
return vec![("".to_string(), 0, "".to_string())];
38+
}
3539
}
3640

3741

@@ -45,4 +49,19 @@ mod tests {
4549
let server = IPFS::new("localhost".to_string(), 5001);
4650
assert_eq!("This is a test", server.cat("/ipfs/QmR6XorNYAywK4q1dRiRN1gmvfLcx3ccBv68iGtAqon9tt".to_string()).trim_right_matches('\n'));
4751
}
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+
}
4867
}

0 commit comments

Comments
 (0)