diff --git a/Makefile b/Makefile index 0091706..9302763 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ run: tailwind-build ## compiles tailwindcss styles and runs the project with cab .PHONY: test test: ## runs the unit test project - cabal test hastl-test --test-show-details=direct + cabal test hastl-test --enable-tests --test-show-details=direct .PHONY: test-integration test-integration: ## runs the integration test project diff --git a/hastl.cabal b/hastl.cabal index 515f60d..8a5f2ab 100644 --- a/hastl.cabal +++ b/hastl.cabal @@ -90,15 +90,18 @@ test-suite hastl-test default-language: GHC2021 other-modules: Api.UserSpec - -- other-extensions: + default-extensions: + OverloadedStrings type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Main.hs build-tool-depends: hspec-discover:hspec-discover build-depends: - base ^>=4.17.2.1, - hastl, - hspec + base ^>=4.17.2.1 + , hastl + , hspec + , persistent-postgresql + , time ghc-options: -threaded -rtsopts -with-rtsopts=-N -fwarn-unused-imports diff --git a/lib/Api/User.hs b/lib/Api/User.hs index 20d6237..b64ba2a 100644 --- a/lib/Api/User.hs +++ b/lib/Api/User.hs @@ -8,7 +8,6 @@ import Control.Monad.Except (MonadIO (liftIO)) import Control.Monad.Logger (logDebugNS, logErrorNS) import Database.Persist.Postgresql ( Entity (..), - PersistStoreRead (get), getEntity, insert, selectFirst, @@ -24,7 +23,6 @@ import Servant ( Proxy (..), ReqBody, ServerError (errBody, errHTTPCode, errHeaders), - addHeader, err404, err500, throwError, @@ -32,14 +30,13 @@ import Servant ( type (:>), ) -import Api.Templates.Helpers.Htmx (hxTarget_) import Api.Templates.User.User (renderUser, renderUsersComponent) import Config (AppT (..)) import Data.Aeson (FromJSON) import Data.Text (Text, pack) import Data.Time (getCurrentTime) import GHC.Generics (Generic) -import Lucid (Html, ToHtml (toHtml), class_, div_, id_, p_, renderBS) +import Lucid (Html, ToHtml (toHtml), class_, div_, id_, renderBS) import Models (User (User), runDb, tryRunDb) import Models qualified as Md import Servant.API.ContentTypes.Lucid (HTML) diff --git a/test/Api/UserSpec.hs b/test/Api/UserSpec.hs index a2e6315..03a1817 100644 --- a/test/Api/UserSpec.hs +++ b/test/Api/UserSpec.hs @@ -1,10 +1,28 @@ -module Api.User.UserSpec where +module Api.UserSpec where -import Test.Hspec (Spec, describe, it, shouldBe) -import hastl.Api.Templates.User (renderUser) +import Api.Templates.User.User (renderUser) +import Control.Monad.IO.Class (liftIO) +import Data.Time (getCurrentTime) +import Models (User (User), userCreatedAt, userEmail, userName) +import Test.Hspec (Spec, before, context, describe, it, shouldBe) + +import Database.Persist.Postgresql ( + Entity (..), + Key (..), + ) spec :: Spec -spec = do - describe "renderUser" $ do - it "renders a user" $ do - renderUser `shouldBe` "