From 49cd88437b3d840a8f2893b66737003b9901b270 Mon Sep 17 00:00:00 2001 From: Andrey Troeglazov Date: Fri, 19 Jul 2024 16:56:38 +0700 Subject: [PATCH] Wire tests and GH actions --- Test/Main.hs | 4 +++- Test/UsersSpec.hs | 33 +++++++++++++++++++++++++++++++++ flake.nix | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Test/UsersSpec.hs diff --git a/Test/Main.hs b/Test/Main.hs index ef1f986..ebdb8e5 100644 --- a/Test/Main.hs +++ b/Test/Main.hs @@ -16,9 +16,11 @@ import Network.Wai import IHP.ControllerPrelude import IHP.ViewPrelude +import Test.UsersSpec + main :: IO () main = hspec do - tests + Test.UsersSpec.tests tests :: Spec tests = aroundAll (withIHPApp WebApplication config) do diff --git a/Test/UsersSpec.hs b/Test/UsersSpec.hs new file mode 100644 index 0000000..40f96f1 --- /dev/null +++ b/Test/UsersSpec.hs @@ -0,0 +1,33 @@ +module Test.UsersSpec where + +import IHP.Prelude + +import IHP.FrameworkConfig +import IHP.Test.Mocking +import IHP.HaskellSupport +import IHP.ModelSupport +import Test.Hspec +import Config + +import Generated.Types +import Web.Routes +import Web.Types +import Web.FrontController +import Network.Wai +import IHP.ControllerPrelude +import IHP.ViewPrelude +import Network.HTTP.Types.Status + +tests :: Spec +tests = aroundAll (withIHPApp WebApplication config) do + describe "Users" do + it "should show users list on users page" $ withContext do + user <- newRecord @User + |> set #email "test@example.com" + |> createRecord + + response <- withUser user do + callAction UsersAction + + response `responseBodyShouldContain` "test@example.com" + diff --git a/flake.nix b/flake.nix index c1a43ee..322726a 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,7 @@ hlint jwt mmark + hspec ]; };