Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Minor test improvements (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
awegrzyn authored Mar 20, 2020
1 parent 488e78c commit 7ddf338
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions test/testFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ BOOST_AUTO_TEST_CASE(missformatedUrl)
BOOST_CHECK_THROW(influxdb::InfluxDBFactory::Get("localhost:8086?db=test"), InfluxDBException);
}

BOOST_AUTO_TEST_CASE(missingDb)
{
BOOST_CHECK_THROW(influxdb::InfluxDBFactory::Get("http://localhost:8086"), InfluxDBException);
}

} // namespace test
} // namespace influxdb
11 changes: 4 additions & 7 deletions test/testHttp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
namespace influxdb {
namespace test {



BOOST_AUTO_TEST_CASE(write1)
{
auto influxdb = influxdb::InfluxDBFactory::Get("http://localhost:8086?db=test");
Expand All @@ -26,6 +24,10 @@ BOOST_AUTO_TEST_CASE(write1)
influxdb->write(Point{"test"}
.addField("value", 200LL)
.addTag("host", "localhost"));

influxdb->write(Point{"string"}
.addField("value", "influxdb-cxx")
.addTag("host", "localhost"));
}

BOOST_AUTO_TEST_CASE(writeWrongHost)
Expand All @@ -34,10 +36,5 @@ BOOST_AUTO_TEST_CASE(writeWrongHost)
BOOST_CHECK_THROW(influxdb->write(Point{"test"}.addField("value", 10)), InfluxDBException);
}

BOOST_AUTO_TEST_CASE(writeNoDb)
{
BOOST_CHECK_THROW(influxdb::InfluxDBFactory::Get("http://localhost:8086"), InfluxDBException);
}

} // namespace test
} // namespace influxdb
8 changes: 8 additions & 0 deletions test/testQuery.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BOOST_AUTO_TEST_CASE(query1)
{
auto influxdb = influxdb::InfluxDBFactory::Get("http://localhost:8086?db=test");
auto points = influxdb->query("SELECT * from test WHERE host = 'localhost' LIMIT 3");
BOOST_CHECK_EQUAL(points.size(), 3);
BOOST_CHECK_EQUAL(points[0].getName(), "test");
BOOST_CHECK_EQUAL(points[1].getName(), "test");
BOOST_CHECK_EQUAL(points[2].getName(), "test");
Expand All @@ -21,5 +22,12 @@ BOOST_AUTO_TEST_CASE(query1)
BOOST_CHECK_EQUAL(points[2].getFields(), "value=200");
}

BOOST_AUTO_TEST_CASE(failedQuery1)
{
auto influxdb = influxdb::InfluxDBFactory::Get("http://localhost:8086?db=test");
auto points = influxdb->query("SELECT * from test1 WHERE host = 'localhost' LIMIT 3");
BOOST_CHECK_EQUAL(points.size(), 0);
}

} // namespace test
} // namespace influxdb

0 comments on commit 7ddf338

Please sign in to comment.