Skip to content

Commit c1e83f8

Browse files
committed
Enforce minimum 0.4.0 verision and use tmp file for host file test.
1 parent 021a882 commit c1e83f8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/test/java/org/ipfs/api/Test.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package org.ipfs.api;
22

33
import java.io.*;
4-
import java.util.Arrays;
5-
import java.util.List;
6-
import java.util.Map;
7-
import java.util.Optional;
8-
import java.util.Random;
4+
import java.nio.file.*;
5+
import java.util.*;
96

107
import static org.junit.Assert.assertTrue;
118

@@ -65,8 +62,13 @@ public void hugeFileStreamTest() {
6562
}
6663

6764
@org.junit.Test
68-
public void hostFileTest() {
69-
NamedStreamable hostFile = new NamedStreamable.FileWrapper(new File("Makefile"));
65+
public void hostFileTest() throws IOException {
66+
Path tempFile = Files.createTempFile("IPFS", "tmp");
67+
BufferedWriter w = new BufferedWriter(new FileWriter(tempFile.toFile()));
68+
w.append("Some data");
69+
w.flush();
70+
w.close();
71+
NamedStreamable hostFile = new NamedStreamable.FileWrapper(tempFile.toFile());
7072
fileTest(hostFile);
7173
}
7274

@@ -348,7 +350,9 @@ public void diagTest() {
348350
public void toolsTest() {
349351
try {
350352
String version = ipfs.version();
351-
assertTrue(version.equals("0.4.0-dev")); // No longer works with any 0.3 version
353+
int major = Integer.parseInt(version.split("\\.")[0]);
354+
int minor = Integer.parseInt(version.split("\\.")[1]);
355+
assertTrue(major >= 0 && minor >= 4); // Requires at least 0.4.0
352356
Map commands = ipfs.commands();
353357
} catch (IOException e) {
354358
throw new RuntimeException(e);

0 commit comments

Comments
 (0)