2
2
{-# OPTIONS_GHC -Wno-orphans #-}
3
3
{-# LANGUAGE DisambiguateRecordFields #-}
4
4
{-# LANGUAGE NamedFieldPuns #-}
5
+ {-# LANGUAGE TypeOperators #-}
5
6
module Main
6
7
( main
7
8
) where
@@ -75,11 +76,13 @@ codeActionUnitTests = testGroup "Code Action Tests"
75
76
licenseErrorSuggestion " Unknown license identifier: 'BSD3' Do you mean BSD-3-Clause?" @?= [] ,
76
77
77
78
testCase " BSD-3-Clause" $ do
78
- licenseErrorSuggestion " Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?" @?= [(" BSD3" , " BSD-3-Clause" )],
79
+ take 2 (licenseErrorSuggestion " Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?" )
80
+ @?= [(" BSD3" ," BSD-3-Clause" ),(" BSD3" ," BSD-3-Clause-LBNL" )],
79
81
80
- testCase " MIT " $ do
82
+ testCase " MiT " $ do
81
83
-- contains no suggestion
82
- licenseErrorSuggestion " Unknown SPDX license identifier: 'MIT3'" @?= [(" MIT3" , " MIT" )]
84
+ take 2 (licenseErrorSuggestion " Unknown SPDX license identifier: 'MiT'" )
85
+ @?= [(" MiT" ," MIT" ),(" MiT" ," MIT-0" )]
83
86
]
84
87
85
88
-- ------------------------------------------------------------------------
@@ -139,7 +142,7 @@ pluginTests recorder = testGroup "Plugin Tests"
139
142
length diags @?= 1
140
143
reduceDiag ^. J. range @?= Range (Position 3 24 ) (Position 4 0 )
141
144
reduceDiag ^. J. severity @?= Just DsError
142
- [codeAction] <- getLicenseAction " BSD-3-Clause" <$> getCodeActions doc (Range (Position 3 24 ) (Position 4 0 ))
145
+ [codeAction] <- getLicenseAction " BSD-3-Clause" <$> getCodeActions doc (Range (Position 3 24 ) (Position 4 0 ))
143
146
executeCodeAction codeAction
144
147
contents <- documentContents doc
145
148
liftIO $ contents @?= Text. unlines
@@ -154,14 +157,14 @@ pluginTests recorder = testGroup "Plugin Tests"
154
157
]
155
158
, runCabalTestCaseSession " Apache-2.0" recorder " " $ do
156
159
doc <- openDoc " licenseCodeAction2.cabal" " cabal"
157
- diags <- waitForDiagnosticsFromSource doc " parsing "
160
+ diags <- waitForDiagnosticsFromSource doc " cabal "
158
161
-- test if it supports typos in license name, here 'apahe'
159
- reduceDiag <- liftIO $ inspectDiagnostic diags [" Unknown SPDX license identifier: 'apahe '" ]
162
+ reduceDiag <- liftIO $ inspectDiagnostic diags [" Unknown SPDX license identifier: 'APAHE '" ]
160
163
liftIO $ do
161
164
length diags @?= 1
162
165
reduceDiag ^. J. range @?= Range (Position 3 25 ) (Position 4 0 )
163
166
reduceDiag ^. J. severity @?= Just DsError
164
- [codeAction] <- getLicenseAction " Apache-2.0" <$> getCodeActions doc (Range (Position 3 24 ) (Position 4 0 ))
167
+ [codeAction] <- getLicenseAction " Apache-2.0" <$> getCodeActions doc (Range (Position 3 24 ) (Position 4 0 ))
165
168
executeCodeAction codeAction
166
169
contents <- documentContents doc
167
170
liftIO $ contents @?= Text. unlines
@@ -177,10 +180,10 @@ pluginTests recorder = testGroup "Plugin Tests"
177
180
]
178
181
]
179
182
where
180
- getLicenseAction :: Text. Text -> [( |? ) Command CodeAction ] -> [CodeAction ]
183
+ getLicenseAction :: Text. Text -> [Command |? CodeAction ] -> [CodeAction ]
181
184
getLicenseAction license codeActions = do
182
185
InR action@ CodeAction {_title} <- codeActions
183
- guard (_title== " Replace with " <> license)
186
+ guard (_title== " Replace with " <> license)
184
187
pure action
185
188
186
189
-- ------------------------------------------------------------------------
0 commit comments