package com.foxx.androidcast.crash;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import java.io.File;

public class CrashReportStoreTest {
    @org.junit.Rule
    public TemporaryFolder tmp = new TemporaryFolder();

    @Test
    public void pendingFile_usesSessionStyleTimestamp() throws Exception {
        File files = tmp.newFolder("files");
        long ms = 1_704_067_200_000L; // 2024-01-01 00:00:00 UTC — pattern only
        File f = CrashReportStore.newPendingFile(files, ms);
        assertTrue(f.getName().matches("crash_\\d{8}_\\d{6}\\.json"));
    }

    @Test
    public void formatTimestamp_matchesSessionStatsPattern() {
        String stamp = CrashReportStore.formatTimestamp(171_000_000_0000L);
        assertEquals(15, stamp.length());
        assertTrue(stamp.contains("_"));
    }
}
