-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ __pycache__/ | |
*.bak | ||
|
||
.gitmessage | ||
.approval_tests_temp/ |
22 changes: 22 additions & 0 deletions
22
approvaltests-tests/src/test/java/org/approvaltests/ApprovedFileLogTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.approvaltests; | ||
|
||
import com.spun.util.io.FileUtils; | ||
import org.approvaltests.namer.ApprovalNamer; | ||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
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())); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ltests-tests/src/test/java/org/approvaltests/ApprovedFileLogTest.testLogging.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
anything |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
approvaltests/src/main/java/org/approvaltests/ApprovedFileLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.approvaltests; | ||
|
||
import com.spun.util.io.FileUtils; | ||
|
||
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters