Skip to content

Commit

Permalink
Add integration test for rendering all swagger stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
fisx committed Dec 10, 2024
1 parent 4432e83 commit 4e5b3a2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions integration/test/Test/Swagger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Data.String.Conversions
import GHC.Stack
import System.Exit
import System.FilePath
import System.IO (writeFile)
import System.IO.Temp (createTempDirectory)
import System.Process
import Testlib.Assertions
import Testlib.Prelude
Expand Down Expand Up @@ -127,3 +129,21 @@ testSwaggerLint sw = do
liftIO $ putStrLn out
liftIO $ putStrLn err
assertFailure "swagger validation errors"

testRenderAllSwaggers :: (HasCallStack) => App ()
testRenderAllSwaggers = do
tempdir <- liftIO $ createTempDirectory "/tmp/" "wire-swagger-versions"
putStrLn $ "testRenderAllSwaggers: writing to " <> tempdir
let writeSwagger :: String -> Response -> App ()
writeSwagger filename resp = do
content <- show <$> resp.json
liftIO $ writeFile (tempdir </> filename <> ".json") content

for_ existingVersions $ \v -> do
bindResponse (BrigP.getSwaggerPublicAllJson v) $ \resp -> do
resp.status `shouldMatchInt` 200
writeSwagger (show v) resp
for_ (Set.toList internalApis) $ \a -> do
bindResponse (BrigP.getSwaggerInternalJson a) $ \resp -> do
resp.status `shouldMatchInt` 200
writeSwagger a resp

0 comments on commit 4e5b3a2

Please sign in to comment.