Skip to content

Commit

Permalink
added second test with Path option to directly specify the file
Browse files Browse the repository at this point in the history
  • Loading branch information
wsobel committed Jan 26, 2024
1 parent f81d26c commit 854999e
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test_package/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,4 +2371,69 @@ DevicesStyle { Location = /styles/styles.xsl }

m_config->stop();
}

TEST_F(ConfigTest, should_update_stylesheet_versions_with_path)
{
fs::path root {createTempDirectory("14")};

fs::path styleDir { root / "styles" };
fs::create_directory(styleDir);

fs::path styles { styleDir / "styles.xsl" };
copyFile("styles/styles.xsl", styles, 0min);

fs::path devices(root / "Devices.xml");
copySampleFile("empty.xml", devices, 0min);

fs::path config {root / "agent.cfg"};
{
ofstream cfg(config.string());
cfg << R"DOC(
SchemaVersion = 2.2
)DOC";
cfg << "Devices = " << devices << endl;
cfg << R"DOC(
DevicesStyle {
Location = /styles/styles.xsl
Path = ./styles/styles.xsl
}
)DOC";

}

boost::program_options::variables_map options;
boost::program_options::variable_value value(boost::optional<string>(config.string()), false);
options.insert(make_pair("config-file"s, value));

m_config->initialize(options);

ifstream file(styles);
ASSERT_TRUE(file.is_open());

stringstream sf;
sf << file.rdbuf();

ASSERT_EQ(R"DOC(<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:m="urn:mtconnect.org:MTConnectDevices:2.2"
xmlns:s="urn:mtconnect.org:MTConnectStreams:2.2"
xmlns:e="urn:mtconnect.org:MTConnectError:2.2"
xmlns:js="urn:custom-javascript"
exclude-result-prefixes="msxsl js"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<!-- Root template -->
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet>
)DOC", sf.str());

m_config->stop();
}

} // namespace

0 comments on commit 854999e

Please sign in to comment.