Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(plugins/DbCopy): solve directory creation failure due to limited permissions #5824

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/src/test/java/org/tron/plugins/DbCopyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DbCopyTest extends DbTest {
@Test
public void testRun() {
String[] args = new String[] { "db", "cp", INPUT_DIRECTORY,
tmpDir + UUID.randomUUID()};
genarateTmpDir()};
Assert.assertEquals(0, cli.execute(args));
}

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

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

Expand Down
10 changes: 10 additions & 0 deletions plugins/src/test/java/org/tron/plugins/DbTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,14 @@ private static void initDB(File file) throws IOException {
}
}
}

/**
* Generate a not-exist temporary directory path.
* @return temporary path
*/
public String genarateTmpDir() {
File dir = Paths.get(tmpDir, UUID.randomUUID().toString()).toFile();
dir.deleteOnExit();
return dir.getPath();
}
}
Loading