diff --git a/nri-redis/src/Redis.hs b/nri-redis/src/Redis.hs index dd263bcb..bae175b8 100644 --- a/nri-redis/src/Redis.hs +++ b/nri-redis/src/Redis.hs @@ -38,6 +38,8 @@ module Redis setex, setnx, eval, + script, + ScriptParam (..), -- * Running Redis queries Internal.query, @@ -62,6 +64,7 @@ import qualified NonEmptyDict import qualified Redis.Codec as Codec import qualified Redis.Handler as Handler import qualified Redis.Internal as Internal +import Redis.Script (ScriptParam (..), script) import qualified Redis.Script as Script import qualified Redis.Settings as Settings import qualified Prelude @@ -189,5 +192,5 @@ makeApi Codec.Codec {Codec.codecEncoder, Codec.codecDecoder} toKey = set = \key value -> Internal.Set (toKey key) (codecEncoder value), setex = \key seconds value -> Internal.Setex (toKey key) seconds (codecEncoder value), setnx = \key value -> Internal.Setnx (toKey key) (codecEncoder value), - eval = \script -> Internal.Eval script + eval = \script' -> Internal.Eval script' } diff --git a/nri-redis/test/Spec/Redis.hs b/nri-redis/test/Spec/Redis.hs index 394c671d..925657f3 100644 --- a/nri-redis/test/Spec/Redis.hs +++ b/nri-redis/test/Spec/Redis.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE QuasiQuotes #-} + module Spec.Redis (tests) where import qualified Control.Concurrent.MVar as MVar @@ -369,7 +371,11 @@ queryTests redisHandler = |> Expect.equal (List.length expectedKeys) keySet |> Set.toList - |> Expect.equal expectedKeys + |> Expect.equal expectedKeys, + Test.test "eval runs and returns something" <| \() -> do + let script = [Redis.script|return 1|] + result <- Redis.eval intJsonApi script |> Redis.query testNS |> Expect.succeeds + Expect.equal result 1 ] where testNS = addNamespace "testNamespace" redisHandler @@ -396,6 +402,9 @@ sortedSetApi = Redis.SortedSet.textApi identity jsonApi' :: Redis.Api Text [Int] jsonApi' = Redis.jsonApi identity +intJsonApi :: Redis.Api Text Prelude.Integer +intJsonApi = Redis.jsonApi identity + -- | Timestamps recorded in spans would make each test result different from the -- last. This helper sets all timestamps to zero to prevent this. --