summaryrefslogtreecommitdiff
path: root/Biz/Devalloc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Devalloc.hs')
-rw-r--r--Biz/Devalloc.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/Biz/Devalloc.hs b/Biz/Devalloc.hs
index 4645a2a..3836ef7 100644
--- a/Biz/Devalloc.hs
+++ b/Biz/Devalloc.hs
@@ -40,6 +40,7 @@
-- : dep servant-server
-- : dep tasty
-- : dep tasty-hunit
+-- : dep tasty-quickcheck
-- : dep uuid
-- : dep vector
-- : dep warp
@@ -353,8 +354,7 @@ test :: Test.Tree
test =
Test.group
"Biz.Devalloc"
- [ -- test_analyzeGitHub,
- test_calculateScore
+ [ test_calculateScore
]
-- * app configurations
@@ -934,7 +934,12 @@ analyze keep askedBy activeAuthors url bareRepo = do
third (_, _, a) = a
git args = Process.readProcess "git" (["--git-dir", bareRepo] ++ args) ""
+-- | Does the aggregate score calculation given number of files found to be
+-- blackholes, liabilities, etc.
calculateScore :: Double -> Double -> Double -> Integer
+calculateScore 0 _ _ = 0
+calculateScore a 0 0 | a > 0 = 100
+calculateScore a b c | a < 0 || b < 0 || c < 0 = 0
calculateScore numTotal numBlackholes numLiabilities =
max 0 <. round
<| maxScore
@@ -952,7 +957,9 @@ test_calculateScore =
"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
+ Test.unit "all liabilities" <| 70 @=? calculateScore 100 0 100,
+ Test.prop "never > 100" <| \t b l -> calculateScore t b l <= 100,
+ Test.prop "never < 0" <| \t b l -> calculateScore t b l >= 0
]
lastTouched :: FilePath -> FilePath -> IO (FilePath, Int)
@@ -1054,10 +1061,6 @@ analyzeGitHub keep user cfg o r = do
ghOwner = GitHub.mkName (Proxy :: Proxy GitHub.Owner) o
ghRepo = GitHub.mkName (Proxy :: Proxy GitHub.Repo) r
--- 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.
fetchBareRepo :: Config -> Text -> IO FilePath