Add test for write-read-role
This commit is contained in:
parent
a4376be4ae
commit
5ef82d94ac
@ -37,6 +37,8 @@ script:
|
||||
- stack test -- esqueleto:postgresql
|
||||
- stack test -- esqueleto:sqlite
|
||||
- stack test -- esqueleto:mysql || exit 0 # TODO: Remove that exit 0 when mysql tests are checking correctly
|
||||
- cd test/expected-compile-failures/
|
||||
- bash test.sh
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
||||
3
test/expected-compile-failures/.gitignore
vendored
Normal file
3
test/expected-compile-failures/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.stack-work/
|
||||
expected-compile-failures.cabal
|
||||
*~
|
||||
3
test/expected-compile-failures/ChangeLog.md
Normal file
3
test/expected-compile-failures/ChangeLog.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Changelog for expected-compile-failures
|
||||
|
||||
## Unreleased changes
|
||||
30
test/expected-compile-failures/LICENSE
Normal file
30
test/expected-compile-failures/LICENSE
Normal file
@ -0,0 +1,30 @@
|
||||
Copyright Author name here (c) 2018
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Author name here nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
1
test/expected-compile-failures/README.md
Normal file
1
test/expected-compile-failures/README.md
Normal file
@ -0,0 +1 @@
|
||||
# expected-compile-failures
|
||||
2
test/expected-compile-failures/Setup.hs
Normal file
2
test/expected-compile-failures/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
33
test/expected-compile-failures/package.yaml
Normal file
33
test/expected-compile-failures/package.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
name: expected-compile-failures
|
||||
version: 0.1.0.0
|
||||
github: bitemyapp/esqueleto
|
||||
license: BSD3
|
||||
author: Matt Parsons
|
||||
maintainer: parsonsmatt@gmail.com
|
||||
copyright: 2018 Matt Parsons
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
- ChangeLog.md
|
||||
|
||||
description: Please see the README on GitHub at <https://github.com/bitemyapp/esqueleto/test/expected-compile-failures#readme>
|
||||
|
||||
dependencies:
|
||||
- base >= 4.7 && < 5
|
||||
- esqueleto
|
||||
- persistent
|
||||
- persistent-template
|
||||
|
||||
library:
|
||||
source-dirs: src
|
||||
|
||||
executables:
|
||||
write-with-read-role:
|
||||
main: Main.hs
|
||||
source-dirs: write-read-role
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -rtsopts
|
||||
- -with-rtsopts=-N
|
||||
dependencies:
|
||||
- expected-compile-failures
|
||||
1
test/expected-compile-failures/src/Lib.hs
Normal file
1
test/expected-compile-failures/src/Lib.hs
Normal file
@ -0,0 +1 @@
|
||||
module Lib where
|
||||
5
test/expected-compile-failures/stack.yaml
Normal file
5
test/expected-compile-failures/stack.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
resolver: lts-12.24
|
||||
|
||||
packages:
|
||||
- .
|
||||
- ../../../esqueleto
|
||||
5
test/expected-compile-failures/test.sh
Normal file
5
test/expected-compile-failures/test.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/env bash
|
||||
|
||||
STACK_YAML=stack.yaml
|
||||
|
||||
stack build --fast expected-compile-failures:exe:write-with-read-role && exit 1
|
||||
53
test/expected-compile-failures/write-read-role/Main.hs
Normal file
53
test/expected-compile-failures/write-read-role/Main.hs
Normal file
@ -0,0 +1,53 @@
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE NoMonomorphismRestriction #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-}
|
||||
|
||||
module Main where
|
||||
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
import Database.Persist.Sql (SqlReadT)
|
||||
import Database.Esqueleto (SqlExpr, SqlQuery, from,
|
||||
val, (<#), insertSelect, (<&>), (^.))
|
||||
import Database.Esqueleto.Internal.Language (Insertion)
|
||||
import Database.Persist.TH (mkDeleteCascade,
|
||||
mkMigrate, mkPersist,
|
||||
persistLowerCase, share,
|
||||
sqlSettings)
|
||||
|
||||
main :: IO ()
|
||||
main = pure ()
|
||||
|
||||
share [ mkPersist sqlSettings
|
||||
, mkDeleteCascade sqlSettings
|
||||
, mkMigrate "migrateAll"] [persistLowerCase|
|
||||
Person
|
||||
name String
|
||||
age Int Maybe
|
||||
deriving Eq Show
|
||||
BlogPost
|
||||
title String
|
||||
authorId PersonId
|
||||
deriving Eq Show
|
||||
Follow
|
||||
follower PersonId
|
||||
followed PersonId
|
||||
deriving Eq Show
|
||||
|]
|
||||
|
||||
writeQuery :: SqlQuery (SqlExpr (Insertion BlogPost))
|
||||
writeQuery =
|
||||
from $ \p ->
|
||||
return $ BlogPost <# (val "Group Blog Post") <&> (p ^. PersonId)
|
||||
|
||||
shouldFail :: MonadIO m => SqlReadT m ()
|
||||
shouldFail = insertSelect writeQuery
|
||||
Loading…
Reference in New Issue
Block a user