summaryrefslogtreecommitdiff
path: root/Biz/Test.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-01-26 18:04:14 -0500
committerBen Sima <ben@bsima.me>2021-01-26 18:09:35 -0500
commit0ec6b06acee62b57a50ed9718b8da31fced18c4d (patch)
tree3112d481c0b0cb58eabb9f826305c867a4d4acfd /Biz/Test.hs
parent699d17db81d3508548934d39b92edb01700b3c9a (diff)
Add user subscription field
Also improved the test situation, did some refactors, and now listing the user's past analyses on their account page.
Diffstat (limited to 'Biz/Test.hs')
-rw-r--r--Biz/Test.hs45
1 files changed, 44 insertions, 1 deletions
diff --git a/Biz/Test.hs b/Biz/Test.hs
index 7f6da61..7571008 100644
--- a/Biz/Test.hs
+++ b/Biz/Test.hs
@@ -8,12 +8,16 @@ module Biz.Test
group,
unit,
prop,
+ with,
(@=?),
+ (@?=),
+ (@?!=),
)
where
+import Alpha hiding (group)
import qualified Test.Tasty as Tasty
-import Test.Tasty.HUnit ((@=?))
+import Test.Tasty.HUnit ((@=?), (@?=))
import qualified Test.Tasty.HUnit as HUnit
import qualified Test.Tasty.QuickCheck as QuickCheck
@@ -27,3 +31,42 @@ unit = HUnit.testCase
prop :: QuickCheck.Testable a => Tasty.TestName -> a -> Tasty.TestTree
prop = QuickCheck.testProperty
+
+with ::
+ -- | Startup
+ IO a ->
+ -- | Shutdown
+ (a -> IO ()) ->
+ -- | A test group where the first argument is a function that gets the resource
+ (IO a -> Tree) ->
+ Tree
+with = Tasty.withResource
+
+-- | How is this not part of HUnit??
+assertNotEqual ::
+ (Eq a, Show a, HasCallStack) =>
+ -- | The message prefix
+ String ->
+ -- | The not-expected value
+ a ->
+ -- | The actual value
+ a ->
+ HUnit.Assertion
+assertNotEqual preface notexpected actual =
+ unless (actual /= notexpected) (HUnit.assertFailure msg)
+ where
+ msg =
+ (if null preface then "" else preface ++ "\n")
+ ++ "expected not: "
+ ++ show notexpected
+ ++ "\n but got: "
+ ++ show actual
+
+(@?!=) ::
+ (Eq a, Show a, HasCallStack) =>
+ -- | The not-expected value
+ a ->
+ -- | The actual value
+ a ->
+ HUnit.Assertion
+expected @?!= actual = assertNotEqual "" expected actual