package com.ankurm.testing;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class FileServiceTest {
    private Path tempFile;

    @Test
    void testFileWriting() throws IOException {
        tempFile = Files.createTempFile("test_report", ".txt");
        Files.writeString(tempFile, "Hello JUnit");
        // Assertions...
    }

    @AfterEach
    void deleteTempFiles() throws IOException {
        if (tempFile != null) {
            Files.deleteIfExists(tempFile);
            System.out.println("Deleted temporary file: " + tempFile.getFileName().toString().replaceAll("\\d{6,}", "<random>"));
        }
    }
}
