From 0ec6b06acee62b57a50ed9718b8da31fced18c4d Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 26 Jan 2021 18:04:14 -0500 Subject: Add user subscription field Also improved the test situation, did some refactors, and now listing the user's past analyses on their account page. --- Biz/Test.hs | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'Biz/Test.hs') 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 -- cgit v1.2.3