summaryrefslogtreecommitdiff
path: root/test/http/file_test_utilities.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/http/file_test_utilities.hpp')
-rw-r--r--test/http/file_test_utilities.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/http/file_test_utilities.hpp b/test/http/file_test_utilities.hpp
new file mode 100644
index 0000000000..073a0747a4
--- /dev/null
+++ b/test/http/file_test_utilities.hpp
@@ -0,0 +1,19 @@
+#pragma once
+#include <filesystem>
+#include <string>
+#include <string_view>
+
+#include <gtest/gtest.h>
+
+inline std::string makeFile(std::string_view sampleData)
+{
+ std::filesystem::path path = std::filesystem::temp_directory_path();
+ path /= "bmcweb_http_response_test_XXXXXXXXXXX";
+ std::string stringPath = path.string();
+ int fd = mkstemp(stringPath.data());
+ EXPECT_GT(fd, 0);
+ EXPECT_EQ(write(fd, sampleData.data(), sampleData.size()),
+ sampleData.size());
+ close(fd);
+ return stringPath;
+}