diff options
author | Ben Sima <ben@bsima.me> | 2021-01-15 21:11:30 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-01-15 21:13:33 -0500 |
commit | e77cdc025b0e80049344f258d9ca170d0953d0d7 (patch) | |
tree | 71b1a438a8f715992627b644dcba7468ef036a09 /Biz/Devalloc.hs | |
parent | 7bb2775667386659402ebb7559c7bc4af46ec268 (diff) |
Implement Biz.Test with tasty
Also changes the --test option to a 'test' command. This is because running the
tests for a namespace/exe should never be combined with anything else: you
either want to run the tests, or not.
Diffstat (limited to 'Biz/Devalloc.hs')
-rw-r--r-- | Biz/Devalloc.hs | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/Biz/Devalloc.hs b/Biz/Devalloc.hs index 1134098..59e2240 100644 --- a/Biz/Devalloc.hs +++ b/Biz/Devalloc.hs @@ -32,6 +32,8 @@ -- : dep servant-auth-server -- : dep servant-lucid -- : dep servant-server +-- : dep tasty +-- : dep tasty-hunit -- : dep uuid -- : dep vector -- : dep warp @@ -45,6 +47,8 @@ import Alpha hiding ((<.>)) import Biz.App (CSS (..), HtmlApp (..)) import qualified Biz.Cli as Cli import qualified Biz.Look +import Biz.Test ((@=?)) +import qualified Biz.Test as Test import qualified Clay import qualified Control.Exception as Exception import Crypto.JOSE.JWK (JWK) @@ -203,10 +207,8 @@ help = devalloc Usage: - devalloc [--test] - -Options: - --test Run the tests + devalloc + devalloc test |] move :: Cli.Arguments -> IO () @@ -250,8 +252,13 @@ testCookieSettings = Auth.cookieXsrfSetting = Nothing } -test :: Cli.Arguments -> IO () -test _ = test_analyzeGitHub >> pure test_calculateScore >> pure () +test :: Test.Tree +test = + Test.group + "Biz.Devalloc" + [ -- test_analyzeGitHub, + test_calculateScore + ] -- * app configurations @@ -760,15 +767,14 @@ calculateScore numTotal numBlackholes numLiabilities = numGood = numTotal - numBlackholes - numLiabilities maxScore = 100.0 -test_calculateScore :: [Bool] +test_calculateScore :: Test.Tree test_calculateScore = - [ -- perfect - 100 == calculateScore 100 0 0, - -- all blackholes - 50 == calculateScore 100 100 0, - -- all liabilities - 70 == calculateScore 100 0 100 - ] + Test.group + "calculateScore" + [ Test.unit "perfect score" <| 100 @=? calculateScore 100 0 0, + Test.unit "all blackholes" <| 50 @=? calculateScore 100 100 0, + Test.unit "all liabilities" <| 70 @=? calculateScore 100 0 100 + ] lastTouched :: FilePath -> FilePath -> IO (FilePath, Int) lastTouched bareRepo path = do @@ -869,8 +875,9 @@ analyzeGitHub githubAuth cfg o r = do ghOwner = GitHub.mkName (Proxy :: Proxy GitHub.Owner) o ghRepo = GitHub.mkName (Proxy :: Proxy GitHub.Repo) r -test_analyzeGitHub :: IO Analysis -test_analyzeGitHub = analyzeGitHub () Envy.defConfig "bsima" "bin" +-- TODO: write this test +-- test_analyzeGitHub :: IO Analysis +-- test_analyzeGitHub = analyzeGitHub () Envy.defConfig "bsima" "bin" -- | Clone the repo to @<Config.depo>/<url>@. If repo already exists, just do a -- @git fetch@. Returns the full path to the local repo. |