Skip to content

Commit 880a803

Browse files
committed
Make test more robust
1 parent 6232fb7 commit 880a803

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/functional/Format.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Control.Lens ((^.))
66
import Control.Monad.IO.Class
77
import Data.Aeson
88
import qualified Data.ByteString.Lazy as BS
9+
import qualified Data.Text as T
910
import qualified Data.Text.Encoding as T
1011
import qualified Data.Text.IO as T
1112
import Language.LSP.Test
@@ -47,8 +48,7 @@ providerTests = testGroup "formatting provider" [
4748
testCase "respects none" $ runSessionWithConfig (formatConfig "none") hlsCommand fullCaps "test/testdata/format" $ do
4849
doc <- openDoc "Format.hs" "haskell"
4950
resp <- request STextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing)
50-
liftIO $ resp ^. LSP.result @?= Left (ResponseError InvalidRequest "No plugin enabled for STextDocumentFormatting, available:\nPluginId \"floskell\"\nPluginId \"fourmolu\"\nPluginId \"ormolu\"\nPluginId \"stylish-haskell\"\nPluginId \"brittany\"\n" Nothing)
51-
51+
liftIO $ foramattingNoneResultCorrect (resp ^. LSP.result) @? "Result incorrect"
5252
, requiresOrmoluPlugin . requiresFloskellPlugin $ testCase "can change on the fly" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
5353
formattedOrmolu <- liftIO $ T.readFile "test/testdata/format/Format.ormolu.formatted.hs"
5454
formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.formatted.hs"
@@ -81,6 +81,10 @@ providerTests = testGroup "formatting provider" [
8181
formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing)
8282
documentContents doc >>= liftIO . (@?= formattedFloskell)
8383
]
84+
where
85+
foramattingNoneResultCorrect (Left (ResponseError InvalidRequest text Nothing)) =
86+
T.isPrefixOf "No plugin enabled for STextDocumentFormatting" text
87+
foramattingNoneResultCorrect _ = False
8488

8589
formatLspConfig :: Value -> Value
8690
formatLspConfig provider = object [ "haskell" .= object ["formattingProvider" .= (provider :: Value)] ]

0 commit comments

Comments
 (0)