Skip to content

Commit 85d643b

Browse files
committed
fix test
1 parent c40e1c5 commit 85d643b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/test/java/io/ipfs/api/RecursiveAddTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.*;
44
import java.nio.file.*;
5+
import java.util.*;
56

67
import org.junit.Assert;
78
import org.junit.Test;
@@ -14,14 +15,19 @@ public class RecursiveAddTest {
1415

1516
@Test
1617
public void testAdd() throws Exception {
17-
18-
String TEST_HASH = "QmWVMRbFTrA6pMhsfXzsyoWqmrhy5FPd4VitfX79R5bguw";
19-
2018
System.out.println("ipfs version: " + ipfs.version());
21-
System.out.println("pwd: " + new File("").getAbsolutePath());
22-
23-
Path path = Paths.get("src/test/resources/html");
24-
MerkleNode node = ipfs.add(new NamedStreamable.FileWrapper(path.toFile())).get(0);
25-
Assert.assertEquals(TEST_HASH, node.hash.toBase58());
19+
20+
String EXPECTED = "QmX5fZ6aUxNTAS7ZfYc8f4wPoMx6LctuNbMjuJZ9EmUSr6";
21+
22+
Path base = Paths.get("tmpdata");
23+
base.toFile().mkdirs();
24+
Files.write(base.resolve("index.html"), "<html></html>".getBytes());
25+
Path js = base.resolve("js");
26+
js.toFile().mkdirs();
27+
Files.write(js.resolve("func.js"), "function() {console.log('Hey');}".getBytes());
28+
29+
List<MerkleNode> add = ipfs.add(new NamedStreamable.FileWrapper(base.toFile()));
30+
MerkleNode node = add.get(add.size() - 1);
31+
Assert.assertEquals(EXPECTED, node.hash.toBase58());
2632
}
2733
}

0 commit comments

Comments
 (0)