Ed Tanous | 7a6f003 | 2024-01-28 09:49:03 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | #include <filesystem> |
| 3 | #include <string> |
| 4 | #include <string_view> |
| 5 | |
| 6 | #include <gtest/gtest.h> |
| 7 | |
| 8 | inline std::string makeFile(std::string_view sampleData) |
| 9 | { |
| 10 | std::filesystem::path path = std::filesystem::temp_directory_path(); |
| 11 | path /= "bmcweb_http_response_test_XXXXXXXXXXX"; |
| 12 | std::string stringPath = path.string(); |
| 13 | int fd = mkstemp(stringPath.data()); |
| 14 | EXPECT_GT(fd, 0); |
| 15 | EXPECT_EQ(write(fd, sampleData.data(), sampleData.size()), |
| 16 | sampleData.size()); |
| 17 | close(fd); |
| 18 | return stringPath; |
| 19 | } |