summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitsutoshiAoe <>2014-06-03 11:22:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-06-03 11:22:00 (GMT)
commite8011f42096036c46622c2179c354634d24cbfa9 (patch)
treed52d457fb67d6fb0eeda6a18495932d852494f2b
parent154186f50b8b9be27ad7af7e792ff7edf84a1c32 (diff)
version 0.3.00.3.0
-rw-r--r--CHANGELOG.md6
-rw-r--r--influxdb.cabal4
-rw-r--r--src/Database/InfluxDB/Decode.hs2
-rw-r--r--src/Database/InfluxDB/Encode.hs2
-rw-r--r--src/Database/InfluxDB/Http.hs12
-rw-r--r--src/Database/InfluxDB/Types.hs2
-rw-r--r--tests/test-suite.hs24
7 files changed, 38 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75d0097..01593a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## v0.3.3 - 2014-06-03
+
+* Support for InfluxDB v0.7
+ * Renamed `username` field for `/cluster_admins` to `user`
+ * No support for the old field name
+
## v0.2.2 - 2014-05-08
* Support for retry-0.4
diff --git a/influxdb.cabal b/influxdb.cabal
index 8d58530..f929267 100644
--- a/influxdb.cabal
+++ b/influxdb.cabal
@@ -1,5 +1,5 @@
name: influxdb
-version: 0.2.2
+version: 0.3.0
synopsis: Haskell client library for InfluxDB
description: Haskell client library for InfluxDB
homepage: https://github.com/maoe/influxdb-haskell
@@ -141,5 +141,5 @@ source-repository head
source-repository this
type: git
- tag: v0.2.2
+ tag: v0.3.0
location: https://github.com/maoe/influxdb-haskell.git
diff --git a/src/Database/InfluxDB/Decode.hs b/src/Database/InfluxDB/Decode.hs
index f733974..13ac513 100644
--- a/src/Database/InfluxDB/Decode.hs
+++ b/src/Database/InfluxDB/Decode.hs
@@ -47,7 +47,7 @@ fromSeries = runParser . parseSeries
-- > data Event = Event Text EventType
-- > data EventType = Login | Logout
-- >
--- > instance FromSeriesData where
+-- > instance FromSeriesData Event where
-- > parseSeriesData = withValues $ \values -> Event
-- > <$> values .: "user"
-- > <*> values .: "type"
diff --git a/src/Database/InfluxDB/Encode.hs b/src/Database/InfluxDB/Encode.hs
index 8b5f9b4..d812268 100644
--- a/src/Database/InfluxDB/Encode.hs
+++ b/src/Database/InfluxDB/Encode.hs
@@ -27,7 +27,7 @@ class ToSeries a where
-- > data Event = Event Text EventType
-- > data EventType = Login | Logout
-- >
--- > instance ToSeriesData where
+-- > instance ToSeriesData Event where
-- > toSeriesColumn _ = V.fromList ["user", "type"]
-- > toSeriesPoints (Event user ty) = V.fromList [toValue user, toValue ty]
-- >
diff --git a/src/Database/InfluxDB/Http.hs b/src/Database/InfluxDB/Http.hs
index 1768f1c..5016263 100644
--- a/src/Database/InfluxDB/Http.hs
+++ b/src/Database/InfluxDB/Http.hs
@@ -76,7 +76,7 @@ import Data.Aeson ((.=))
import Data.Default.Class (Default(def))
import qualified Data.Aeson as A
import qualified Data.Aeson.Encode as AE
-import qualified Data.Attoparsec as P
+import qualified Data.Attoparsec.ByteString as P
import qualified Network.HTTP.Client as HC
import Database.InfluxDB.Decode
@@ -442,7 +442,7 @@ addClusterAdmin
addClusterAdmin Config {..} name password = do
void $ httpLbsWithRetry configServerPool makeRequest configHttpManager
return Admin
- { adminUsername = name
+ { adminName = name
}
where
makeRequest = def
@@ -474,12 +474,12 @@ updateClusterAdminPassword Config {..} admin password =
[ "password" .= password
]
, HC.path = escapeString $ printf "/cluster_admins/%s"
- (T.unpack adminUsername)
+ (T.unpack adminName)
, HC.queryString = escapeString $ printf "u=%s&p=%s"
(T.unpack credsUser)
(T.unpack credsPassword)
}
- Admin {adminUsername} = admin
+ Admin {adminName} = admin
Credentials {..} = configCreds
-- | Delete a cluster administrator. Requires cluster admin privilege.
@@ -493,12 +493,12 @@ deleteClusterAdmin Config {..} admin =
makeRequest = def
{ HC.method = "DELETE"
, HC.path = escapeString $ printf "/cluster_admins/%s"
- (T.unpack adminUsername)
+ (T.unpack adminName)
, HC.queryString = escapeString $ printf "u=%s&p=%s"
(T.unpack credsUser)
(T.unpack credsPassword)
}
- Admin {adminUsername} = admin
+ Admin {adminName} = admin
Credentials {..} = configCreds
-- | List database users.
diff --git a/src/Database/InfluxDB/Types.hs b/src/Database/InfluxDB/Types.hs
index 13d2d19..626f2aa 100644
--- a/src/Database/InfluxDB/Types.hs
+++ b/src/Database/InfluxDB/Types.hs
@@ -193,7 +193,7 @@ data User = User
-- | Administrator
newtype Admin = Admin
- { adminUsername :: Text
+ { adminName :: Text
} deriving Show
diff --git a/tests/test-suite.hs b/tests/test-suite.hs
index 6510197..fbd8f81 100644
--- a/tests/test-suite.hs
+++ b/tests/test-suite.hs
@@ -129,6 +129,24 @@ case_post_multi_points = runTest $ \config ->
[series] -> fromSeriesData series @?= Right [Val 42, Val 42, Val 42]
_ -> assertFailure $ "Expect one series, but got: " ++ show ss
+case_query_nonexistent_series :: Assertion
+case_query_nonexistent_series = runTest $ \config ->
+ withTestDatabase config $ \database -> do
+ name <- liftIO newName
+ ss <- query config database $ "select * from " <> name
+ ss @?= ([] :: [SeriesData])
+
+case_query_empty_series :: Assertion
+case_query_empty_series = runTest $ \config ->
+ withTestDatabase config $ \database -> do
+ name <- liftIO newName
+ post config database $
+ writeSeries name $ Val 42
+ ss1 <- query config database $ "delete from " <> name
+ ss1 @?= ([] :: [SeriesData])
+ ss2 <- query config database $ "select * from " <> name
+ ss2 @?= ([] :: [SeriesData])
+
case_queryChunked :: Assertion
case_queryChunked = runTest $ \config ->
withTestDatabase config $ \database -> do
@@ -194,7 +212,7 @@ case_list_cluster_admins :: Assertion
case_list_cluster_admins = runTest $ \config -> do
admins <- listClusterAdmins config
assertBool "No root admin" $
- any (("root" ==) . adminUsername) admins
+ any (("root" ==) . adminName) admins
case_authenticate_cluster_admin :: Assertion
case_authenticate_cluster_admin = runTest authenticateClusterAdmin
@@ -205,11 +223,11 @@ case_add_then_delete_cluster_admin = runTest $ \config -> do
admin <- addClusterAdmin config name "somePassword"
listClusterAdmins config >>= \admins ->
assertBool ("No such admin: " ++ T.unpack name) $
- any ((name ==) . adminUsername) admins
+ any ((name ==) . adminName) admins
deleteClusterAdmin config admin
listClusterAdmins config >>= \admins ->
assertBool ("Found a deleted admin: " ++ T.unpack name) $
- all ((name /=) . adminUsername) admins
+ all ((name /=) . adminName) admins
case_update_cluster_admin_password :: Assertion
case_update_cluster_admin_password = runTest $ \config -> do