list test
This commit is contained in:
parent
c92875882a
commit
f400f43b8c
@ -58,7 +58,7 @@ data ListOptions = ListOptions
|
||||
, lHideOld :: Bool
|
||||
, lShowNightly :: Bool
|
||||
, lRawFormat :: Bool
|
||||
}
|
||||
} deriving (Eq, Show)
|
||||
|
||||
|
||||
|
||||
|
@ -424,6 +424,7 @@ test-suite ghcup-optparse-test
|
||||
InstallTest
|
||||
UnsetTest
|
||||
RmTest
|
||||
ListTest
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall
|
||||
build-depends: base, ghcup, ghcup-optparse, tasty, tasty-hunit, optparse-applicative, versions, text, uri-bytestring
|
||||
|
@ -65,7 +65,7 @@ import qualified Data.Text as T
|
||||
data ListCriteria = ListInstalled Bool
|
||||
| ListSet Bool
|
||||
| ListAvailable Bool
|
||||
deriving Show
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | A list result describes a single tool version
|
||||
-- and various of its properties.
|
||||
|
36
test/optparse-test/ListTest.hs
Normal file
36
test/optparse-test/ListTest.hs
Normal file
@ -0,0 +1,36 @@
|
||||
module ListTest where
|
||||
import Test.Tasty
|
||||
import GHCup.OptParse
|
||||
import Utils
|
||||
import GHCup.List
|
||||
import GHCup.Types
|
||||
|
||||
|
||||
listTests :: TestTree
|
||||
listTests = buildTestTree listParseWith ("list", listCheckList)
|
||||
|
||||
defaultOptions :: ListOptions
|
||||
defaultOptions = ListOptions Nothing Nothing Nothing Nothing False False False
|
||||
|
||||
listCheckList :: [(String, ListOptions)]
|
||||
listCheckList =
|
||||
[ ("list", defaultOptions)
|
||||
, ("list -t ghc", defaultOptions{loTool = Just GHC})
|
||||
, ("list -t cabal", defaultOptions{loTool = Just Cabal})
|
||||
, ("list -t hls", defaultOptions{loTool = Just HLS})
|
||||
, ("list -t stack", defaultOptions{loTool = Just Stack})
|
||||
, ("list -c installed", defaultOptions{lCriteria = Just $ ListInstalled True})
|
||||
, ("list -c +installed", defaultOptions{lCriteria = Just $ ListInstalled True})
|
||||
, ("list -c -installed", defaultOptions{lCriteria = Just $ ListInstalled False})
|
||||
, ("list -c set", defaultOptions{lCriteria = Just $ ListSet True})
|
||||
, ("list -c +set", defaultOptions{lCriteria = Just $ ListSet True})
|
||||
, ("list -c -set", defaultOptions{lCriteria = Just $ ListSet False})
|
||||
, ("list -c available", defaultOptions{lCriteria = Just $ ListAvailable True})
|
||||
, ("list -c +available", defaultOptions{lCriteria = Just $ ListAvailable True})
|
||||
, ("list -c -available", defaultOptions{lCriteria = Just $ ListAvailable False})
|
||||
]
|
||||
|
||||
listParseWith :: [String] -> IO ListOptions
|
||||
listParseWith args = do
|
||||
List a <- parseWith args
|
||||
pure a
|
@ -8,6 +8,7 @@ import qualified ConfigTest
|
||||
import qualified InstallTest
|
||||
import qualified UnsetTest
|
||||
import qualified RmTest
|
||||
import qualified ListTest
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMain $ testGroup "ghcup"
|
||||
@ -18,4 +19,5 @@ main = defaultMain $ testGroup "ghcup"
|
||||
, InstallTest.installTests
|
||||
, UnsetTest.unsetTests
|
||||
, RmTest.rmTests
|
||||
, ListTest.listTests
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user