Skip to content

Commit

Permalink
refactor:
Browse files Browse the repository at this point in the history
tidy cleanup of files for filestore tests
  • Loading branch information
fractalwrench committed Apr 19, 2018
1 parent 7bc8576 commit 45e8a35
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void setUp() throws Exception {
config = client.config;
errorStore = client.errorStore;
errorStorageDir = errorStore.storageDir;
FileUtils.clearFilesInDir(errorStorageDir);
FileUtils.clearFiles(errorStore);
}

/**
Expand All @@ -54,7 +54,7 @@ public void setUp() throws Exception {
*/
@After
public void tearDown() throws Exception {
FileUtils.clearFilesInDir(errorStorageDir);
FileUtils.clearFiles(errorStore);
}

@Test
Expand Down
8 changes: 7 additions & 1 deletion sdk/src/androidTest/java/com/bugsnag/android/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ final class FileUtils {
private FileUtils() {
}

static void clearFilesInDir(File storageDir) {
static void clearFiles(FileStore fileStore) {
File storageDir = fileStore.storageDir;
clearFilesInDir(storageDir);
clearFilesInDir(new File(fileStore.oldDirectory));
}

private static void clearFilesInDir(File storageDir) {
if (!storageDir.isDirectory()) {
throw new IllegalArgumentException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void setUp() throws Exception {
Client client = new Client(InstrumentationRegistry.getContext(), "api-key");
sessionStore = client.sessionStore;
storageDir = sessionStore.storageDir;
FileUtils.clearFilesInDir(storageDir);
FileUtils.clearFiles(sessionStore);
}

/**
Expand All @@ -44,7 +44,7 @@ public void setUp() throws Exception {
*/
@After
public void tearDown() throws Exception {
FileUtils.clearFilesInDir(storageDir);
FileUtils.clearFiles(sessionStore);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class SessionTrackingPayloadTest {
private AppData appData;

private SessionStore sessionStore;
private File storageDir;

/**
* Configures a session tracking payload and session store, ensuring that 0 files are present
Expand All @@ -38,8 +37,7 @@ public void setUp() throws Exception {
Context context = InstrumentationRegistry.getContext();
Client client = new Client(context, "api-key");
sessionStore = client.sessionStore;
storageDir = sessionStore.storageDir;
FileUtils.clearFilesInDir(storageDir);
FileUtils.clearFiles(sessionStore);

session = generateSession();
appData = new AppData(context, new Configuration("a"), generateSessionTracker());
Expand All @@ -54,7 +52,7 @@ public void setUp() throws Exception {
*/
@After
public void tearDown() throws Exception {
FileUtils.clearFilesInDir(storageDir);
FileUtils.clearFiles(sessionStore);
}

@Test
Expand Down

0 comments on commit 45e8a35

Please sign in to comment.