[websockets] some tests fixes

But they still don't work because there is no HasClient implemented
for the websocket server.
parent db5ec697
Pipeline #6243 failed with stages
......@@ -931,6 +931,7 @@ test-suite garg-test-tasty
Test.API.Routes
Common
Test.API.Setup
Test.Core.AsyncUpdates
Test.Core.Similarity
Test.Core.Text
Test.Core.Text.Corpus.Query
......
......@@ -14,7 +14,6 @@ TODO-SECURITY: Critical
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.API.Admin.Settings
where
......@@ -25,7 +24,7 @@ import Control.Monad.Logger (LogLevel(..))
import Control.Monad.Reader
import Data.ByteString.Lazy qualified as L
import Data.Pool (Pool)
import qualified Data.Pool as Pool
import Data.Pool qualified as Pool
import Database.PostgreSQL.Simple (Connection, connect, close, ConnectInfo)
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Admin.Settings.CORS
......@@ -38,8 +37,7 @@ import Gargantext.Core.NLP (nlpServerMap)
import Gargantext.Core.NodeStory
import Gargantext.Database.Prelude (databaseParameters, hasConfig)
import Gargantext.Prelude
import Gargantext.Prelude.Config (gc_js_job_timeout, gc_js_id_timeout)
import Gargantext.Prelude.Config ({-GargConfig(..),-} {-gc_repofilepath,-} readConfig)
import Gargantext.Prelude.Config (gc_js_job_timeout, gc_js_id_timeout, readConfig)
import Gargantext.Prelude.Mail qualified as Mail
import Gargantext.Prelude.NLP qualified as NLP
import Gargantext.System.Logging
......@@ -55,6 +53,7 @@ import System.Directory
import System.IO (hClose)
import System.IO.Temp (withTempFile)
devSettings :: FilePath -> IO Settings
devSettings jwkFile = do
jwkExists <- doesFileExist jwkFile
......@@ -204,7 +203,6 @@ newEnv logger port file = do
!nlp_env <- nlpServerMap <$> NLP.readConfig file
!central_exchange <- forkIO CE.gServer
!dispatcher <- D.dispatcher
{- An 'Env' by default doesn't have strict fields, but when constructing one in production
......
......@@ -40,7 +40,7 @@ data CEMessage =
-- UpdateJobProgress (JobID 'Safe) (JM.JobEntry (JobID 'Safe) (Seq JobLog) JobLog)
UpdateJobProgress (JobID 'Safe) JobLog
| UpdateTreeFirstLevel NodeId
-- deriving (Eq)
deriving (Eq)
instance Prelude.Show CEMessage where
show (UpdateJobProgress jId jobLog) = "UpdateJobProgress " <> (CBUTF8.decode $ BSL.unpack $ Aeson.encode jId) <> " " <> show jobLog
show (UpdateTreeFirstLevel nodeId) = "UpdateTreeFirstLevel " <> show nodeId
......
......@@ -48,7 +48,7 @@ dispatcher = do
-- let server = wsServer authSettings subscriptions
d_ce_listener <- forkIO (dispatcher_listener subscriptions)
d_ce_listener <- forkIO (dispatcherListener subscriptions)
pure $ Dispatcher { d_subscriptions = subscriptions
-- , d_ws_server = server
......@@ -59,8 +59,8 @@ dispatcher = do
-- | This is a nanomsg socket listener. We want to read the messages
-- | as fast as possible and then process them gradually in a separate
-- | thread.
dispatcher_listener :: SSet.Set Subscription -> IO ()
dispatcher_listener subscriptions = do
dispatcherListener :: SSet.Set Subscription -> IO ()
dispatcherListener subscriptions = do
withSocket Pull $ \s -> do
_ <- bind s AUConstants.dispatcherBind
......
......@@ -6,6 +6,7 @@
module Test.API.Routes where
import Data.Text.Encoding qualified as TE
import Fmt (Builder, (+|), (|+))
import Gargantext.API.Admin.Auth.Types (AuthRequest, AuthResponse, Token)
import Gargantext.API.Ngrams.Types ( NgramsTable, NgramsTablePatch, OrderBy, TabType, Versioned, VersionedWithCount )
......@@ -22,8 +23,7 @@ import Gargantext.API.Types () -- MimeUnrender instances
import Gargantext.API.Errors
import Gargantext.API.Routes.Named.Private hiding (tableNgramsAPI)
import Gargantext.API.Routes.Named.Node
import qualified Servant.Auth.Client as S
import qualified Data.Text.Encoding as TE
import Servant.Auth.Client qualified as S
-- This is for requests made by http.client directly to hand-crafted URLs
curApi :: Builder
......
......@@ -12,6 +12,8 @@ import Gargantext.API.Admin.Settings
import Gargantext.API.Admin.Types
import Gargantext.API.Errors.Types
import Gargantext.API.Prelude
import Gargantext.Core.AsyncUpdates.CentralExchange qualified as CE
import Gargantext.Core.AsyncUpdates.Dispatcher qualified as D
import Gargantext.Core.NLP
import Gargantext.Core.NodeStory
import Gargantext.Core.Types.Individu
......@@ -23,6 +25,7 @@ import Gargantext.Database.Admin.Types.Hyperdata
import Gargantext.Database.Prelude
import Gargantext.Database.Query.Table.Node (getOrMkList)
import Gargantext.Database.Query.Tree.Root (MkCorpusUser(..))
import Gargantext.Prelude (forkIO)
import Gargantext.Prelude.Config
import Gargantext.Prelude.Mail qualified as Mail
import Gargantext.Prelude.NLP qualified as NLP
......@@ -66,6 +69,9 @@ newTestEnv testEnv logger port = do
!config_mail <- Mail.readConfig file
!nlp_env <- nlpServerMap <$> NLP.readConfig file
!central_exchange <- forkIO CE.gServer
!dispatcher <- D.dispatcher
pure $ Env
{ _env_settings = settings'
, _env_logger = logger
......@@ -78,6 +84,8 @@ newTestEnv testEnv logger port = do
, _env_config = config_env
, _env_mail = config_mail
, _env_nlp = nlp_env
, _env_central_exchange = central_exchange
, _env_dispatcher = dispatcher
}
withGargApp :: Application -> (Warp.Port -> IO ()) -> IO ()
......
......@@ -279,6 +279,8 @@ newTestEnv = do
, _env_config = Prelude.error "config not needed, but forced somewhere (check StrictData)"
, _env_mail = Prelude.error "mail not needed, but forced somewhere (check StrictData)"
, _env_nlp = Prelude.error "nlp not needed, but forced somewhere (check StrictData)"
, _env_central_exchange = Prelude.error "central exchange not needed, but forced somewhere (check StrictData)"
, _env_dispatcher = Prelude.error "dispatcher not needed, but forced somewhere (check StrictData)"
}
testFetchJobStatus :: IO ()
......
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