Skip to content

Commit d57efcf

Browse files
jean-philippe-martinpongad
authored andcommitted
GCS NIO: fix one test to work with the other unit tests (#3454)
1 parent 7329839 commit d57efcf

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageReadTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public void testInputStreamReads() throws IOException, InterruptedException {
9191
// reading past the end
9292
int eof = is.read(buf, 0, 1);
9393
assertWithMessage("EOF should return -1").that(eof).isEqualTo(-1);
94+
} finally {
95+
// clean up
96+
Files.delete(p);
9497
}
9598
}
9699
}
@@ -121,6 +124,9 @@ public void testChannelReads() throws IOException, InterruptedException {
121124
buf.clear();
122125
int eof = chan.read(buf);
123126
assertWithMessage("EOF should return -1").that(eof).isEqualTo(-1);
127+
} finally {
128+
// clean up
129+
Files.delete(p);
124130
}
125131
}
126132
}

google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ public void testListFiles() throws IOException {
531531
got.add(path);
532532
}
533533
assertThat(got).containsExactlyElementsIn(goodPaths);
534+
// clean up
535+
for (Path path : paths) {
536+
Files.delete(path);
537+
}
534538
}
535539
}
536540

@@ -556,10 +560,12 @@ public void testDeleteRecursive() throws IOException {
556560

557561
@Test
558562
public void testListFilesInRootDirectory() throws IOException {
563+
// We must explicitly set the storageOptions, because the unit tests
564+
// set the fake storage as default but we want to access the real storage.
559565
CloudStorageFileSystem fs = CloudStorageFileSystem.forBucket(
560566
BUCKET, CloudStorageConfiguration.builder().permitEmptyPathComponents(true)
561-
.build());
562-
567+
.build(), storageOptions);
568+
563569
// test absolute path
564570
Path rootPath = fs.getPath("");
565571
List<String> objectNames = new ArrayList<String>();

0 commit comments

Comments
 (0)