File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
src/test/java/io/ipfs/api Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import java .io .*;
4
4
import java .nio .file .*;
5
+ import java .util .*;
5
6
6
7
import org .junit .Assert ;
7
8
import org .junit .Test ;
@@ -14,14 +15,19 @@ public class RecursiveAddTest {
14
15
15
16
@ Test
16
17
public void testAdd () throws Exception {
17
-
18
- String TEST_HASH = "QmWVMRbFTrA6pMhsfXzsyoWqmrhy5FPd4VitfX79R5bguw" ;
19
-
20
18
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 ());
26
32
}
27
33
}
You can’t perform that action at this time.
0 commit comments