blob: 073a0747a430060f3b1bdd0d2f051900a145a562 [file] [log] [blame]
Ed Tanous7a6f0032024-01-28 09:49:03 -08001#pragma once
2#include <filesystem>
3#include <string>
4#include <string_view>
5
6#include <gtest/gtest.h>
7
8inline 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}