Skip to content

Commit

Permalink
a reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 31, 2024
1 parent b23c767 commit 1a9f733
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

import java.io.File;

public class ApprovedFileLogTest {
@Test
void testLogging() {
File file = ApprovedFileLog.get();
ApprovalNamer approvalNamer = Approvals.createApprovalNamer();
File approvedFile = approvalNamer.getApprovedFile(".txt");
String prelog = FileUtils.readFile(file);
Assert.assertFalse(prelog.contains(approvedFile.getAbsolutePath()));
Approvals.verify("anything");
String postlog = FileUtils.readFile(file);
Assert.assertTrue(postlog.contains(approvedFile.getAbsolutePath()));
}
public class ApprovedFileLogTest
{
@Test
void testLogging()
{
File file = ApprovedFileLog.get();
ApprovalNamer approvalNamer = Approvals.createApprovalNamer();
File approvedFile = approvalNamer.getApprovedFile(".txt");
String prelog = FileUtils.readFile(file);
Assert.assertFalse(prelog.contains(approvedFile.getAbsolutePath()));
Approvals.verify("anything");
String postlog = FileUtils.readFile(file);
Assert.assertTrue(postlog.contains(approvedFile.getAbsolutePath()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ public static void copyFileToDirectory(String file, File tempDir)
throw ObjectUtils.throwAsError(t);
}
}

public static void appendToFile(File file, String text)
public static void appendToFile(File file, String text)
{
try
{
Asserts.assertNotNull("Writing to file: " + file, text);
file.getCanonicalFile().getParentFile().mkdirs();
try (BufferedWriter out = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8, StandardOpenOption.APPEND))
try (BufferedWriter out = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8,
StandardOpenOption.APPEND))
{
out.write(text);
}
Expand Down
31 changes: 17 additions & 14 deletions approvaltests/src/main/java/org/approvaltests/ApprovedFileLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@

import java.io.File;

public class ApprovedFileLog {
static {
FileUtils.writeFile(get(), "");
}
public static File get() {
File file = new File(".approval_tests_temp/.approved_files.log");
FileUtils.createIfNeeded(file.getAbsolutePath());
return file;
}

public static void log(File file) {
File log = get();
FileUtils.appendToFile(log, file.getAbsolutePath() + "\n");
}
public class ApprovedFileLog
{
static
{
FileUtils.writeFile(get(), "");
}
public static File get()
{
File file = new File(".approval_tests_temp/.approved_files.log");
FileUtils.createIfNeeded(file.getAbsolutePath());
return file;
}
public static void log(File file)
{
File log = get();
FileUtils.appendToFile(log, file.getAbsolutePath() + "\n");
}
}

0 comments on commit 1a9f733

Please sign in to comment.