Tests for query
This commit is contained in:
parent
55188f514f
commit
3c1ea67566
@ -84,6 +84,7 @@ test-suite buuka-test
|
||||
, hedgehog
|
||||
, hedgehog-corpus
|
||||
, tasty-hedgehog
|
||||
, tasty-hunit
|
||||
, tasty
|
||||
, text
|
||||
, aeson
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ mkDerivation, aeson, base, bytestring, containers, exceptions
|
||||
, filepath, hashable, hashids, hedgehog, hedgehog-corpus, lens, mtl
|
||||
, optparse-applicative, stdenv, tasty, tasty-hedgehog, text
|
||||
, transformers, unliftio, vector, yaml
|
||||
, optparse-applicative, stdenv, tasty, tasty-hedgehog, tasty-hunit
|
||||
, text, transformers, unliftio, vector, yaml
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "buuka";
|
||||
@ -15,7 +15,8 @@ mkDerivation {
|
||||
];
|
||||
executableHaskellDepends = [ base optparse-applicative unliftio ];
|
||||
testHaskellDepends = [
|
||||
aeson base hedgehog hedgehog-corpus tasty tasty-hedgehog text
|
||||
aeson base hedgehog hedgehog-corpus tasty tasty-hedgehog
|
||||
tasty-hunit text
|
||||
];
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
||||
|
@ -2,8 +2,11 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Data.Query
|
||||
(
|
||||
-- * AST
|
||||
Field(..)
|
||||
|
||||
-- * Combinators
|
||||
startsWith
|
||||
, startsWith
|
||||
, endsWith
|
||||
, (.&&.)
|
||||
|
||||
|
@ -1,6 +1,39 @@
|
||||
module Test.Data.Query where
|
||||
|
||||
import Test.Tasty
|
||||
import Test.Tasty.HUnit
|
||||
|
||||
import Data.Buuka
|
||||
(BuukaEntry(..), URL(..))
|
||||
import Data.Functor.Foldable
|
||||
(cata)
|
||||
import Data.Query
|
||||
|
||||
test_startswith :: Assertion
|
||||
test_startswith = do
|
||||
let entry = BuukaEntry (URL "http://example.com") (Just "foo")
|
||||
cata evaluate (startsWith Url "http://") entry @?= True
|
||||
cata evaluate (startsWith Url "https://") entry @?= False
|
||||
cata evaluate (startsWith Title "foo") entry @?= True
|
||||
cata evaluate (startsWith Title "bar") entry @?= False
|
||||
|
||||
test_endswith :: Assertion
|
||||
test_endswith = do
|
||||
let entry = BuukaEntry (URL "http://example.com") (Just "foo")
|
||||
cata evaluate (endsWith Url "com") entry @?= True
|
||||
cata evaluate (endsWith Url "fi") entry @?= False
|
||||
cata evaluate (endsWith Title "foo") entry @?= True
|
||||
cata evaluate (endsWith Title "bar") entry @?= False
|
||||
|
||||
test_and :: Assertion
|
||||
test_and = do
|
||||
let entry = BuukaEntry (URL "http://example.com") (Just "foo")
|
||||
cata evaluate (startsWith Url "http://" .&&. endsWith Url ".com") entry @?= True
|
||||
cata evaluate (startsWith Url "http://" .&&. endsWith Url ".fi") entry @?= False
|
||||
|
||||
tests :: TestTree
|
||||
tests = testGroup "Data.Query" []
|
||||
tests = testGroup "Data.Query"
|
||||
[ testCase "Queries startsWith" test_startswith
|
||||
, testCase "Queries endsWith" test_endswith
|
||||
, testCase "Queries and" test_and
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user