Skip to content

Commit 3a3a37e

Browse files
authored
Merge pull request #5824 from halibobo1205/test/toolkits
test(plugins/DbCopy): solve directory creation failure due to limited permissions
2 parents afd15a7 + e6f14ed commit 3a3a37e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

plugins/src/test/java/org/tron/plugins/DbCopyTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class DbCopyTest extends DbTest {
1111
@Test
1212
public void testRun() {
1313
String[] args = new String[] { "db", "cp", INPUT_DIRECTORY,
14-
tmpDir + UUID.randomUUID()};
14+
genarateTmpDir()};
1515
Assert.assertEquals(0, cli.execute(args));
1616
}
1717

@@ -32,7 +32,7 @@ public void testNotExist() {
3232
@Test
3333
public void testEmpty() throws IOException {
3434
String[] args = new String[] {"db", "cp", temporaryFolder.newFolder().toString(),
35-
tmpDir + UUID.randomUUID()};
35+
genarateTmpDir()};
3636
Assert.assertEquals(0, cli.execute(args));
3737
}
3838

@@ -46,7 +46,7 @@ public void testDestIsExist() throws IOException {
4646
@Test
4747
public void testSrcIsFile() throws IOException {
4848
String[] args = new String[] {"db", "cp", temporaryFolder.newFile().toString(),
49-
tmpDir + UUID.randomUUID()};
49+
genarateTmpDir()};
5050
Assert.assertEquals(403, cli.execute(args));
5151
}
5252

plugins/src/test/java/org/tron/plugins/DbTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@ private static void initDB(File file) throws IOException {
8686
}
8787
}
8888
}
89+
90+
/**
91+
* Generate a not-exist temporary directory path.
92+
* @return temporary path
93+
*/
94+
public String genarateTmpDir() {
95+
File dir = Paths.get(tmpDir, UUID.randomUUID().toString()).toFile();
96+
dir.deleteOnExit();
97+
return dir.getPath();
98+
}
8999
}

0 commit comments

Comments
 (0)