package de.retest.recheck.util;

import static org.assertj.core.api.Assertions.assertThat;

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

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

class DeleteOnCloseFileInputStreamTest {

	@Test
	void file_should_be_deleted_on_close( @TempDir final Path temp ) throws IOException {
		final Path file = temp.resolve( "foo" );
		Files.createFile( file );
		final InputStream in = new DeleteOnCloseFileInputStream( file.toFile() );

		in.close();

		assertThat( file ).doesNotExist();
	}

}

@@ -614,10 +614,347 @@
 ();%0A%09%7D%0A%0A
+%09@Test%0A%09void already_deleted_file_should_cause_no_exception( @TempDir final Path temp ) throws IOException %7B%0A%09%09final Path file = temp.resolve( %22bar%22 );%0A%09%09Files.createFile( file );%0A%09%09final InputStream in = new DeleteOnCloseFileInputStream( file.toFile() );%0A%0A%09%09Files.delete( file );%0A%09%09in.close();%0A%0A%09%09assertThat( file ).doesNotExist();%0A%09%7D%0A%0A
 %7D%0A

Add failing test