diff options
Diffstat (limited to 'test/redfish-core/lib/metadata_test.cpp')
-rw-r--r-- | test/redfish-core/lib/metadata_test.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/redfish-core/lib/metadata_test.cpp b/test/redfish-core/lib/metadata_test.cpp new file mode 100644 index 0000000000..84365ac53b --- /dev/null +++ b/test/redfish-core/lib/metadata_test.cpp @@ -0,0 +1,52 @@ +#include "file_test_utilities.hpp" +#include "metadata.hpp" + +#include <string> + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +namespace redfish +{ +namespace +{ + +/* +Example from Redfish and OData whitepaper. + +https://www.dmtf.org/sites/default/files/standards/documents/DSP2052_1.0.0.pdf +*/ +constexpr std::string_view content = + "<edmx:Edmx xmlns:edms=\"http://docs.oasis-open.org/odata/ns/edmx\" Version=\"4.0\">\n" + " <edmx:Reference Uri=\"http://contoso.org/schemas/ExternalSchema.xml\">\n" + " <edmx:Include Namespace=\"ExternalNamespace\"/>\n" + " <edmx:Include Namespace=\"Other.Namespace\"/>\n" + " </edmx:Reference>\n" + " <edmx:DataServices>\n" + " <Schema xmlns=\"http://docs.oasis-open.org/odata/ns/edm\" Namespace=\"MyNewNamespace\">\n" + " <ComplexType Name=\"MyDataType\">\n" + " <Property Name=\"MyProperty\" Type=\"ExternalNamespace.ReferencedDataType\"/>\n" + " <Property Name=\"MyProperty2\" Type=\"Other.Namespace.OtherDataType\"/>\n" + " <Property Name=\"MyProperty3\" Type=\"Edm.Int64\"/>\n" + " </ComplexType>\n" + " </Schema>\n" + " </edmx:DataServices>\n" + "</edmx:Edmx>\n"; + +TEST(MetadataGet, GetOneFile) +{ + TemporaryFileHandle file(content); + + std::filesystem::path path{file.stringPath}; + EXPECT_EQ( + getMetadataPieceForFile(path), + std::format(" <edmx:Reference Uri=\"/redfish/v1/schema/{}\">\n" + " <edmx:Include Namespace=\"MyNewNamespace\"/>\n" + " </edmx:Reference>\n", + path.filename().string())); + + EXPECT_EQ(getMetadataPieceForFile("DoesNotExist_v1.xml"), ""); +} + +} // namespace +} // namespace redfish |