Skip to content

Commit

Permalink
test-fileServer-清理由于测试文件功能产生的脏文件
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveZLS committed Nov 12, 2024
1 parent 9699978 commit 731fb37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import net.ximatai.muyun.test.testcontainers.PostgresTestResource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -23,8 +23,8 @@ public class TestChinese {

File fileFirst;

@BeforeEach
public void setup() throws IOException {
@Test
public void test() throws IOException {
fileName = "五月天.txt";
Path filePath = Paths.get("./" + fileName);
List<String> lines = Arrays.asList(
Expand All @@ -34,12 +34,8 @@ public void setup() throws IOException {
);
Files.write(filePath, lines, StandardCharsets.UTF_8);
fileFirst = filePath.toFile();
}

@Test
public void test() throws IOException {
LocalDateTime currentTime = LocalDateTime.now();
System.out.println(currentTime);
fileFirst.deleteOnExit();
fileFirst.delete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void test() throws IOException {
} catch (IOException e) {
System.err.println("文件移动或重命名失败: " + e.getMessage());
}

}

@Test
Expand Down Expand Up @@ -94,7 +95,7 @@ public void test2() throws IOException {
System.out.println(file.getName());
System.out.println(fileGet.getAbsolutePath());
assertEquals(fileGet.getName(), file.getName());

service.delete(id);
}

private String generateBsyUid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ public void test() throws IOException {
String nameByGet2 = response.getHeader("Content-Disposition").split("''")[1];
String nameDecode = URLDecoder.decode(nameByGet2, StandardCharsets.UTF_8);
assertEquals(fileName, nameDecode);
file.deleteOnExit();
}
}

0 comments on commit 731fb37

Please sign in to comment.