From 7ddf338b80add04e742d569a6b300b0816c235f9 Mon Sep 17 00:00:00 2001 From: Adam Wegrzynek Date: Fri, 20 Mar 2020 21:28:37 +0100 Subject: [PATCH] Minor test improvements (#59) --- test/testFactory.cxx | 5 +++++ test/testHttp.cxx | 11 ++++------- test/testQuery.cxx | 8 ++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/test/testFactory.cxx b/test/testFactory.cxx index eaa5dd5e..57a21fe8 100644 --- a/test/testFactory.cxx +++ b/test/testFactory.cxx @@ -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 diff --git a/test/testHttp.cxx b/test/testHttp.cxx index 5cb3de32..6e05263a 100644 --- a/test/testHttp.cxx +++ b/test/testHttp.cxx @@ -8,8 +8,6 @@ namespace influxdb { namespace test { - - BOOST_AUTO_TEST_CASE(write1) { auto influxdb = influxdb::InfluxDBFactory::Get("http://localhost:8086?db=test"); @@ -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) @@ -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 diff --git a/test/testQuery.cxx b/test/testQuery.cxx index 1f27b958..bdea2bc8 100644 --- a/test/testQuery.cxx +++ b/test/testQuery.cxx @@ -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"); @@ -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