diff --git a/src/test/FunGraph/Test/Util.hs b/src/test/FunGraph/Test/Util.hs index 93ab2bd..585ba8c 100644 --- a/src/test/FunGraph/Test/Util.hs +++ b/src/test/FunGraph/Test/Util.hs @@ -79,7 +79,7 @@ mkQueryFunction mkQueryFunction port = do manager <- Network.HTTP.Client.newManager $ setResponseTimeoutSeconds 60 Network.HTTP.Client.defaultManagerSettings - pure $ runHttpRequest manager -- TODO: also 'Just NoGraph' + pure $ runHttpRequest manager where setResponseTimeoutSeconds seconds settings = settings{Network.HTTP.Client.managerResponseTimeout = Network.HTTP.Client.responseTimeoutMicro $ seconds * 1e6} diff --git a/test/web/Spec.hs b/test/web/Spec.hs index 76841de..c88235e 100644 --- a/test/web/Spec.hs +++ b/test/web/Spec.hs @@ -70,23 +70,25 @@ withSpec searchConfig f = Server.withHandlers logger searchConfig mempty testDataFileName $ \handlers -> runWarpTestRandomPort (Server.app handlers) $ \port -> do queryFun <- mkQueryFunction port - let runQuery = fmap parsePPFunctions <$> queryFun id (Just Server.Api.NoGraph) + let runQuery noGraph = fmap parsePPFunctions <$> queryFun id noGraph main' runQuery >>= f where logger = const $ pure () main' - :: (FunGraph.Test.QueryTest -> IO (Either String [FunGraph.Test.PPFunctions])) + :: (Maybe Server.Api.NoGraph -> FunGraph.Test.QueryTest -> IO (Either String [FunGraph.Test.PPFunctions])) -> IO HSpec.Spec main' runQuery = do let testCase test = let (maxCount, _) = FunGraph.Test.queryTest_args test in HSpec.describe (FunGraph.Test.queryTest_name test <> " maxCount=" <> show maxCount) $ do - HSpec.it "contained in top query results" $ do - result <- either fail pure =<< runQuery test - Set.fromList (map IgnorePackage result) - `isSupersetOf` - Set.map IgnorePackage (FunGraph.Test.queryTest_expectedResult test) + HSpec.describe "contained in top query results" $ + forM_ [("with graph", Nothing), ("no graph", Just Server.Api.NoGraph)] $ \(name, noGraph) -> + HSpec.it name $ do + result <- either fail pure =<< runQuery noGraph test + Set.fromList (map IgnorePackage result) + `isSupersetOf` + Set.map IgnorePackage (FunGraph.Test.queryTest_expectedResult test) pure $ HSpec.describe "Integration tests" $ do HSpec.describe "Expected result" $ forM_ FunGraph.Test.allTestCases testCase