Commit 05e42831 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Move tests under a single umbrella (tasty)

parent be44a926
...@@ -5,7 +5,7 @@ cabal-version: 1.12 ...@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: gargantext name: gargantext
version: 0.0.6.9.9.6.2 version: 0.0.6.9.9.6.2
synopsis: Search, map, share synopsis: Search, map, share
description: Please see README.md description: Please see README.md
category: Data category: Data
...@@ -866,6 +866,7 @@ test-suite garg-test ...@@ -866,6 +866,7 @@ test-suite garg-test
Parsers.Types Parsers.Types
Parsers.WOS Parsers.WOS
Utils.Crypto Utils.Crypto
Utils.Jobs
Paths_gargantext Paths_gargantext
hs-source-dirs: hs-source-dirs:
src-test src-test
...@@ -896,6 +897,7 @@ test-suite garg-test ...@@ -896,6 +897,7 @@ test-suite garg-test
build-depends: build-depends:
QuickCheck QuickCheck
, aeson , aeson
, async
, base , base
, boolexpr , boolexpr
, bytestring , bytestring
...@@ -905,11 +907,17 @@ test-suite garg-test ...@@ -905,11 +907,17 @@ test-suite garg-test
, gargantext , gargantext
, gargantext-prelude , gargantext-prelude
, hspec , hspec
, http-client
, http-client-tls
, mtl
, parsec , parsec
, patches-class , patches-class
, patches-map , patches-map
, quickcheck-instances , quickcheck-instances
, servant-job
, stm
, tasty , tasty
, tasty-hspec
, tasty-hunit , tasty-hunit
, tasty-quickcheck , tasty-quickcheck
, text , text
...@@ -917,42 +925,3 @@ test-suite garg-test ...@@ -917,42 +925,3 @@ test-suite garg-test
, unordered-containers , unordered-containers
, validity , validity
default-language: Haskell2010 default-language: Haskell2010
test-suite jobqueue-test
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_gargantext
hs-source-dirs:
tests/queue
default-extensions:
DataKinds
DeriveGeneric
FlexibleContexts
FlexibleInstances
GADTs
GeneralizedNewtypeDeriving
MultiParamTypeClasses
NamedFieldPuns
NoImplicitPrelude
OverloadedStrings
RankNTypes
RecordWildCards
StrictData
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends:
aeson
, async
, base
, containers
, extra
, gargantext
, hspec
, http-client
, http-client-tls
, mtl
, servant-job
, stm
, text
, time
default-language: Haskell2010
...@@ -494,7 +494,6 @@ executables: ...@@ -494,7 +494,6 @@ executables:
- aeson - aeson
- serialise - serialise
tests: tests:
garg-test: garg-test:
main: Main.hs main: Main.hs
...@@ -514,47 +513,35 @@ tests: ...@@ -514,47 +513,35 @@ tests:
- -rtsopts - -rtsopts
- -with-rtsopts=-N - -with-rtsopts=-N
dependencies: dependencies:
- QuickCheck
- aeson - aeson
- async
- base - base
- boolexpr - boolexpr
- bytestring - bytestring
- containers - containers
- duckling
- gargantext - gargantext
- gargantext-prelude - gargantext-prelude
- hspec - hspec
- QuickCheck - http-client
- quickcheck-instances - http-client-tls
- time - mtl
- parsec - parsec
- patches-class - patches-class
- patches-map - patches-map
- duckling - duckling
- quickcheck-instances
- servant-job
- stm
- tasty - tasty
- tasty-hspec
- tasty-hunit - tasty-hunit
- tasty-quickcheck - tasty-quickcheck
- text - text
- time
- unordered-containers - unordered-containers
- validity - validity
jobqueue-test:
main: Main.hs
source-dirs: tests/queue
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- aeson
- async
- base
- containers
- gargantext
- mtl
- hspec
- http-client
- http-client-tls
- servant-job
- stm
- time
# garg-doctest: # garg-doctest:
# main: Main.hs # main: Main.hs
# source-dirs: src-doctest # source-dirs: src-doctest
......
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Core.Text.Corpus.Query where module Core.Text.Corpus.Query (tests) where
import Data.BoolExpr import Data.BoolExpr
import Gargantext.Core.Text.Corpus.Query import Gargantext.Core.Text.Corpus.Query
...@@ -8,9 +8,6 @@ import Prelude ...@@ -8,9 +8,6 @@ import Prelude
import Test.Tasty import Test.Tasty
import Test.Tasty.QuickCheck hiding (Positive) import Test.Tasty.QuickCheck hiding (Positive)
main :: IO ()
main = defaultMain tests
tests :: TestTree tests :: TestTree
tests = testGroup "Boolean Query Engine" [ tests = testGroup "Boolean Query Engine" [
testProperty "Parses 'A OR B'" testParse01 testProperty "Parses 'A OR B'" testParse01
......
...@@ -18,8 +18,8 @@ import Gargantext.Prelude ...@@ -18,8 +18,8 @@ import Gargantext.Prelude
import Gargantext.Core.Utils import Gargantext.Core.Utils
-- | Core.Utils tests -- | Core.Utils tests
test :: IO () test :: Spec
test = hspec $ do test = do
describe "check if groupWithCounts works" $ do describe "check if groupWithCounts works" $ do
it "simple integer array" $ do it "simple integer array" $ do
(groupWithCounts [1, 2, 3, 1, 2, 3]) `shouldBe` [(1, 2), (2, 2), (3, 2)] (groupWithCounts [1, 2, 3, 1, 2, 3]) `shouldBe` [(1, 2), (2, 2), (3, 2)]
......
...@@ -30,8 +30,8 @@ myCooc = HashMap.fromList [((NgramsTerm {unNgramsTerm = "gev au"},NgramsTerm {un ...@@ -30,8 +30,8 @@ myCooc = HashMap.fromList [((NgramsTerm {unNgramsTerm = "gev au"},NgramsTerm {un
test :: IO () test :: Spec
test = hspec $ do test = do
describe "Cross" $ do describe "Cross" $ do
let let
(distanceMap,_,_) = doSimilarityMap Conditional 0 Weak myCooc (distanceMap,_,_) = doSimilarityMap Conditional 0 Weak myCooc
......
...@@ -21,18 +21,32 @@ import qualified Parsers.Date as PD ...@@ -21,18 +21,32 @@ import qualified Parsers.Date as PD
-- import qualified Graph.Distance as GD -- import qualified Graph.Distance as GD
import qualified Graph.Clustering as Graph import qualified Graph.Clustering as Graph
import qualified Utils.Crypto as Crypto import qualified Utils.Crypto as Crypto
import qualified Utils.Jobs as Jobs
import Test.Tasty
import Test.Tasty.Hspec
main :: IO () main :: IO ()
main = do main = do
Utils.test utilSpec <- testSpec "Utils" Utils.test
clusteringSpec <- testSpec "Graph Clustering" Graph.test
dateParserSpec <- testSpec "Date Parsing" PD.testFromRFC3339
cryptoSpec <- testSpec "Crypto" Crypto.test
nlpSpec <- testSpec "NLP" NLP.test
jobsSpec <- testSpec "Jobs" Jobs.test
defaultMain $ testGroup "Gargantext"
[ utilSpec
, clusteringSpec
, dateParserSpec
, cryptoSpec
, nlpSpec
, jobsSpec
, NgramsQuery.tests
, CorpusQuery.tests
]
-- Occ.parsersTest -- Occ.parsersTest
-- Lang.ngramsExtractionTest FR -- Lang.ngramsExtractionTest FR
-- Lang.ngramsExtractionTest EN -- Lang.ngramsExtractionTest EN
-- Metrics.main -- Metrics.main
Graph.test
PD.testFromRFC3339
-- GD.test -- GD.test
Crypto.test
NLP.main
NgramsQuery.main
CorpusQuery.main
...@@ -19,8 +19,8 @@ import Gargantext.Prelude ...@@ -19,8 +19,8 @@ import Gargantext.Prelude
import Gargantext.Core.Text.Terms.Multi import Gargantext.Core.Text.Terms.Multi
main :: IO () test :: Spec
main = hspec $ do test = do
describe "Text that should be cleaned before sending it to NLP tools as micro-services." $ do describe "Text that should be cleaned before sending it to NLP tools as micro-services." $ do
let text = "This is a url http://cnrs.gargantext.org to be remove and another one www.gargantext.org and digits 343242-2332 to be remove and some to keep: 232 231 33." :: Text let text = "This is a url http://cnrs.gargantext.org to be remove and another one www.gargantext.org and digits 343242-2332 to be remove and some to keep: 232 231 33." :: Text
let result = "This is a url to be remove and another one and digits to be remove and some to keep: 232 231 33." let result = "This is a url to be remove and another one and digits to be remove and some to keep: 232 231 33."
......
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeApplications #-}
module Ngrams.Query where module Ngrams.Query (tests) where
import Control.Monad import Control.Monad
import Data.Coerce import Data.Coerce
...@@ -21,9 +21,6 @@ import Test.Tasty ...@@ -21,9 +21,6 @@ import Test.Tasty
import Test.Tasty.HUnit import Test.Tasty.HUnit
main :: IO ()
main = defaultMain tests
tests :: TestTree tests :: TestTree
tests = testGroup "Ngrams" [unitTests] tests = testGroup "Ngrams" [unitTests]
......
...@@ -36,8 +36,8 @@ fromRFC3339Inv :: Either ParseError ZonedTime -> Text ...@@ -36,8 +36,8 @@ fromRFC3339Inv :: Either ParseError ZonedTime -> Text
fromRFC3339Inv (Right z) = toRFC3339 z fromRFC3339Inv (Right z) = toRFC3339 z
fromRFC3339Inv (Left pe) = panic . pack $ show pe fromRFC3339Inv (Left pe) = panic . pack $ show pe
testFromRFC3339 :: IO () testFromRFC3339 :: Spec
testFromRFC3339 = hspec $ do testFromRFC3339 = do
describe "Test fromRFC3339: " $ do describe "Test fromRFC3339: " $ do
it "is the inverse of Duckling's toRFC3339" $ property $ it "is the inverse of Duckling's toRFC3339" $ property $
((==) <*> (fromRFC3339 . fromRFC3339Inv)) . Right . looseZonedTimePrecision ((==) <*> (fromRFC3339 . fromRFC3339Inv)) . Right . looseZonedTimePrecision
......
...@@ -16,11 +16,10 @@ import Test.Hspec ...@@ -16,11 +16,10 @@ import Test.Hspec
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Prelude.Crypto.Hash import Gargantext.Prelude.Crypto.Hash
import Gargantext.Prelude.Utils
-- | Crypto Hash tests -- | Crypto Hash tests
test :: IO () test :: Spec
test = hspec $ do test = do
describe "Hash String with frontend works" $ do describe "Hash String with frontend works" $ do
let text = "To hash with backend" :: Text let text = "To hash with backend" :: Text
let hashed = "8a69a94d164279af2b7d1443ce08da6184b3d7e815406076e148159c284b53c3" :: Hash let hashed = "8a69a94d164279af2b7d1443ce08da6184b3d7e815406076e148159c284b53c3" :: Hash
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE NumericUnderscores #-}
module Main where module Utils.Jobs (test) where
import Control.Concurrent import Control.Concurrent
import qualified Control.Concurrent.Async as Async import qualified Control.Concurrent.Async as Async
...@@ -54,16 +54,6 @@ addJobToSchedule jobt mvar = do ...@@ -54,16 +54,6 @@ addJobToSchedule jobt mvar = do
data Counts = Counts { countAs :: Int, countBs :: Int } data Counts = Counts { countAs :: Int, countBs :: Int }
deriving (Eq, Show) deriving (Eq, Show)
inc, dec :: JobT -> Counts -> Counts
inc A cs = cs { countAs = countAs cs + 1 }
inc B cs = cs { countBs = countBs cs + 1 }
inc C cs = cs
inc D cs = cs
dec A cs = cs { countAs = countAs cs - 1 }
dec B cs = cs { countBs = countBs cs - 1 }
dec C cs = cs
dec D cs = cs
jobDuration, initialDelay :: Int jobDuration, initialDelay :: Int
jobDuration = 100000 jobDuration = 100000
initialDelay = 20000 initialDelay = 20000
...@@ -194,9 +184,6 @@ testTlsManager :: Manager ...@@ -194,9 +184,6 @@ testTlsManager :: Manager
testTlsManager = unsafePerformIO newTlsManager testTlsManager = unsafePerformIO newTlsManager
{-# NOINLINE testTlsManager #-} {-# NOINLINE testTlsManager #-}
shouldBeE :: (MonadIO m, HasCallStack, Show a, Eq a) => a -> a -> m ()
shouldBeE a b = liftIO (shouldBe a b)
withJob :: Env withJob :: Env
-> (JobHandle MyDummyMonad -> () -> MyDummyMonad ()) -> (JobHandle MyDummyMonad -> () -> MyDummyMonad ())
-> IO (SJ.JobStatus 'SJ.Safe JobLog) -> IO (SJ.JobStatus 'SJ.Safe JobLog)
...@@ -362,8 +349,8 @@ testMarkProgress = do ...@@ -362,8 +349,8 @@ testMarkProgress = do
] ]
} }
main :: IO () test :: Spec
main = hspec $ do test = do
describe "job queue" $ do describe "job queue" $ do
it "respects max runners limit" $ it "respects max runners limit" $
testMaxRunners testMaxRunners
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment