Skip to content

Commit

Permalink
Fix TODO: test both with/without graph
Browse files Browse the repository at this point in the history
  • Loading branch information
runeksvendsen committed Oct 29, 2024
1 parent 7d838a1 commit 216bf41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/test/FunGraph/Test/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
16 changes: 9 additions & 7 deletions test/web/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 216bf41

Please sign in to comment.