Skip to content

Commit 0916548

Browse files
committed
Fixed cache test
1 parent f040d94 commit 0916548

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎test_package/file_cache_test.cpp‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,23 +205,27 @@ TEST_F(FileCacheTest, file_cache_should_compress_file_from_io_context)
205205

206206
boost::asio::io_context context;
207207

208-
boost::asio::post(context, [&context, this]() {
209-
auto gzFile = m_cache->getFile("/resources/zipped_file.txt", "gzip, deflate"s, &context);
208+
bool ran {false};
209+
CachedFilePtr gzFile;
210+
boost::asio::post(context, [&context, &ran, &gzFile, this]() {
211+
gzFile = m_cache->getFile("/resources/zipped_file.txt", "gzip, deflate"s, &context);
210212

211213
ASSERT_TRUE(gzFile);
212214
EXPECT_EQ("text/plain", gzFile->m_mimeType);
213215
EXPECT_TRUE(gzFile->m_cached);
214216
EXPECT_TRUE(gzFile->m_pathGz);
215217

218+
ran = true;
216219
context.stop();
217220
});
218221

219-
bool ran {false};
220-
boost::asio::post(context, [&ran] { ran = true; });
221-
222222
context.run();
223223
EXPECT_TRUE(ran);
224-
224+
EXPECT_TRUE(gzFile);
225+
EXPECT_TRUE(gzFile->m_pathGz);
226+
EXPECT_TRUE(fs::exists(*gzFile->m_pathGz));
227+
EXPECT_EQ(zipped, *gzFile->m_pathGz);
228+
225229
// Cleanup
226230
if (fs::exists(zipped))
227231
{

0 commit comments

Comments
 (0)