Skip to content

Commit

Permalink
Verify result of file operations in tests
Browse files Browse the repository at this point in the history
Mostly to silence IDE warnings about lack of checks.
  • Loading branch information
findepi committed Mar 26, 2024
1 parent 866d06c commit 0609b35
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ private static void createTestFileHive(
configureCompression(jobConf, compressionCodec);

File file = File.createTempFile("trino_test", "data");
file.delete();
verify(file.delete());
try {
FileSinkOperator.RecordWriter recordWriter = outputFormat.getHiveRecordWriter(
jobConf,
Expand Down Expand Up @@ -1538,7 +1538,7 @@ private static void createTestFileHive(
}
}
finally {
file.delete();
verify(file.delete());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static com.google.common.base.Verify.verify;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.airlift.concurrent.Threads.daemonThreadsNamed;
import static io.airlift.testing.Assertions.assertBetweenInclusive;
Expand Down Expand Up @@ -157,14 +158,14 @@ public void setUp()
throws Exception
{
tempFile = File.createTempFile("trino_test_orc_page_source_memory_tracking", "orc");
tempFile.delete();
verify(tempFile.delete());
testPreparer = new TestPreparer(tempFile.getAbsolutePath());
}

@AfterAll
public void tearDown()
{
tempFile.delete();
verify(tempFile.delete());
}

@Test
Expand Down Expand Up @@ -348,7 +349,7 @@ private void testMaxReadBytes(int rowCount)
}
List<TestColumn> testColumns = columnBuilder.build();
File tempFile = File.createTempFile("trino_test_orc_page_source_max_read_bytes", "orc");
tempFile.delete();
verify(tempFile.delete());

TestPreparer testPreparer = new TestPreparer(tempFile.getAbsolutePath(), testColumns, rowCount, rowCount);
ConnectorPageSource pageSource = testPreparer.newPageSource(stats, session);
Expand Down Expand Up @@ -380,7 +381,7 @@ private void testMaxReadBytes(int rowCount)
pageSource.close();
}
finally {
tempFile.delete();
verify(tempFile.delete());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TestingHiveConnectorFactory(Path localFileSystemRootPath, Optional<HiveMe
{
this.metastore = requireNonNull(metastore, "metastore is null");

localFileSystemRootPath.toFile().mkdirs();
boolean ignored = localFileSystemRootPath.toFile().mkdirs();
this.module = binder -> {
newMapBinder(binder, String.class, TrinoFileSystemFactory.class)
.addBinding("local").toInstance(new LocalFileSystemFactory(localFileSystemRootPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ final class TestFileHiveMetastore
throws IOException
{
tempDir = createTempDirectory("test");
tempDir.toFile().mkdirs();
LocalFileSystemFactory fileSystemFactory = new LocalFileSystemFactory(tempDir);

metastore = new FileHiveMetastore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.IOException;
import java.nio.file.Path;

import static com.google.common.base.Verify.verify;
import static com.google.common.io.MoreFiles.deleteRecursively;
import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
import static io.trino.plugin.hive.metastore.glue.TestingGlueHiveMetastore.createTestingGlueHiveMetastore;
Expand All @@ -33,7 +34,7 @@ final class TestGlueHiveMetastore
throws IOException
{
tempDir = createTempDirectory("test");
tempDir.toFile().mkdirs();
verify(tempDir.toFile().mkdirs());
metastore = createTestingGlueHiveMetastore(tempDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@

import java.io.File;

import static com.google.common.base.Verify.verify;

public final class TestingFileHiveMetastore
{
private TestingFileHiveMetastore() {}

public static FileHiveMetastore createTestingFileHiveMetastore(File catalogDirectory)
{
catalogDirectory.mkdirs();
verify(catalogDirectory.mkdirs());
return createTestingFileHiveMetastore(
new LocalFileSystemFactory(catalogDirectory.toPath()),
Location.of("local:///"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public TestingIcebergConnectorFactory(
Path localFileSystemRootPath,
Optional<Module> icebergCatalogModule)
{
localFileSystemRootPath.toFile().mkdirs();
boolean ignored = localFileSystemRootPath.toFile().mkdirs();
this.icebergCatalogModule = requireNonNull(icebergCatalogModule, "icebergCatalogModule is null");
this.module = binder -> {
newMapBinder(binder, String.class, TrinoFileSystemFactory.class)
Expand Down

0 comments on commit 0609b35

Please sign in to comment.