From: fr33domlover
The runner isn't being used, I just added it there so that we can start
writing tests with it. May wish to move it to a TestImport module once
we split crowdmatch tests into multiple modules.
---
crowdmatch/crowdmatch.cabal | 1 +
crowdmatch/test/main.hs | 16 +++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/crowdmatch/crowdmatch.cabal b/crowdmatch/crowdmatch.cabal
index d378766..27b8dfc 100644
--- a/crowdmatch/crowdmatch.cabal
+++ b/crowdmatch/crowdmatch.cabal
@@ -67,6 +67,7 @@ test-suite test
, run-persist
, safe-exceptions
, stripe-core
+, stripe-haskell
, text
, time
, transformers
diff --git a/crowdmatch/test/main.hs b/crowdmatch/test/main.hs
index 96a0244..df2b8ce 100644
--- a/crowdmatch/test/main.hs
+++ b/crowdmatch/test/main.hs
@@ -14,6 +14,7 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Reader (ask)
import Data.Foldable (traverse_)
import Data.List (partition)
+import Data.Maybe (fromJust)
import Data.Monoid ((<>))
import Data.Text (Text)
import Data.Time (getCurrentTime)
@@ -22,7 +23,7 @@ import Database.Persist.Postgresql
(SqlPersistT, runMigration, connEscapeName, unSingle, rawSql,
rawExecute)
import RunPersist (runPersistPool)
import System.Directory (createDirectoryIfMissing)
-import System.Environment (setEnv)
+import System.Environment (lookupEnv, setEnv)
import Test.Hspec
( runIO
, hspec
@@ -47,9 +48,11 @@ import Test.QuickCheck
, getPositive
, counterexample)
import Test.QuickCheck.Monadic (PropertyM, monadicIO, run, pick, monitor,
assert)
+import Web.Stripe (StripeKey(..), StripeConfig(..))
import Web.Stripe.Balance (BalanceTransaction(..))
import Web.Stripe.Charge (Charge(..))
import Web.Stripe.Customer (Customer(..), CustomerId(..), TokenId(..),
customerId)
+import Web.Stripe.Error (StripeError)
import qualified Data.ByteString.Char8 as B
import qualified Data.Text as T
import qualified Database.PostgreSQL.Simple as PG
@@ -96,6 +99,17 @@ dummyStripe state = \case
pure (Right Charge{ chargeBalanceTransaction = Nothing })
BalanceTransactionI _ -> pure (Right BalanceTransaction{})
+-- | A real Stripe runner for tests that really use Stripe, except it uses the
+-- test key so the money is imaginary.
+--
+-- FIXME: The key is fetched here from the environment. But the Snowdrift test
+-- suite currently fetches it from test-settings.yaml and ignores the
+-- environment.
+mkTesterStripe :: MonadIO io => io (StripeI a -> io (Either StripeError a))
+mkTesterStripe = do
+key <- liftIO $ fromJust <$> lookupEnv "STRIPE_SECRET_TEST_KEY"
+return $ runStripe $ StripeConfig $ StripeKey $ B.pack key
+
type Runner = SqlRunner IO IO
-- | A QuickCheck property that uses database actions
--
1.9.1
___
Dev mailing list
Dev@lists.snowdrift.coop
https://lists.snowdrift.coop/mailman/listinfo/dev