Skip to content

Commit 4f167b1

Browse files
pbrisbinnuttycom
authored andcommitted
Fix inverted conditional
1 parent 3b9e175 commit 4f167b1

File tree

5 files changed

+138
-16
lines changed

5 files changed

+138
-16
lines changed

dbmigrations.cabal

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,47 @@ library
114114
if impl(ghc >= 8.10)
115115
ghc-options: -Wno-missing-safe-haskell-mode
116116

117+
executable dbm-sqlite
118+
main-is: Main.hs
119+
other-modules:
120+
Paths_dbmigrations
121+
hs-source-dirs:
122+
sqlite/app
123+
default-extensions:
124+
BangPatterns
125+
DataKinds
126+
DeriveAnyClass
127+
DeriveFoldable
128+
DeriveFunctor
129+
DeriveGeneric
130+
DeriveLift
131+
DeriveTraversable
132+
DerivingStrategies
133+
FlexibleContexts
134+
FlexibleInstances
135+
GADTs
136+
GeneralizedNewtypeDeriving
137+
LambdaCase
138+
MultiParamTypeClasses
139+
NoImplicitPrelude
140+
NoMonomorphismRestriction
141+
OverloadedStrings
142+
RankNTypes
143+
ScopedTypeVariables
144+
StandaloneDeriving
145+
TypeApplications
146+
TypeFamilies
147+
ghc-options: -fwrite-ide-info -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -threaded -rtsopts "-with-rtsopts=-N"
148+
build-depends:
149+
HDBC-sqlite3
150+
, base <5
151+
, dbmigrations
152+
default-language: GHC2021
153+
if impl(ghc >= 9.2)
154+
ghc-options: -Wno-missing-kind-signatures
155+
if impl(ghc >= 8.10)
156+
ghc-options: -Wno-missing-safe-haskell-mode
157+
117158
test-suite spec
118159
type: exitcode-stdio-1.0
119160
main-is: Spec.hs
@@ -126,7 +167,6 @@ test-suite spec
126167
FilesystemParseSpec
127168
FilesystemSerializeSpec
128169
FilesystemSpec
129-
HDBCSpec
130170
InMemoryStore
131171
LinearMigrationsSpec
132172
MigrationsSpec
@@ -160,9 +200,7 @@ test-suite spec
160200
TypeFamilies
161201
ghc-options: -fwrite-ide-info -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -threaded -rtsopts "-with-rtsopts=-N"
162202
build-depends:
163-
HDBC
164-
, HDBC-sqlite3
165-
, base <5
203+
base <5
166204
, containers
167205
, dbmigrations
168206
, directory
@@ -179,3 +217,47 @@ test-suite spec
179217
ghc-options: -Wno-missing-kind-signatures
180218
if impl(ghc >= 8.10)
181219
ghc-options: -Wno-missing-safe-haskell-mode
220+
221+
test-suite sqlite-spec
222+
type: exitcode-stdio-1.0
223+
main-is: Main.hs
224+
other-modules:
225+
Paths_dbmigrations
226+
hs-source-dirs:
227+
sqlite/tests
228+
default-extensions:
229+
BangPatterns
230+
DataKinds
231+
DeriveAnyClass
232+
DeriveFoldable
233+
DeriveFunctor
234+
DeriveGeneric
235+
DeriveLift
236+
DeriveTraversable
237+
DerivingStrategies
238+
FlexibleContexts
239+
FlexibleInstances
240+
GADTs
241+
GeneralizedNewtypeDeriving
242+
LambdaCase
243+
MultiParamTypeClasses
244+
NoImplicitPrelude
245+
NoMonomorphismRestriction
246+
OverloadedStrings
247+
RankNTypes
248+
ScopedTypeVariables
249+
StandaloneDeriving
250+
TypeApplications
251+
TypeFamilies
252+
ghc-options: -fwrite-ide-info -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -threaded -rtsopts "-with-rtsopts=-N"
253+
build-depends:
254+
HDBC
255+
, HDBC-sqlite3
256+
, base <5
257+
, dbmigrations
258+
, hspec
259+
default-language: GHC2021
260+
if impl(ghc >= 9.2)
261+
ghc-options: -Wno-missing-kind-signatures
262+
if impl(ghc >= 8.10)
263+
ghc-options: -Wno-missing-safe-haskell-mode

package.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,21 @@ library:
9090
- time
9191
- yaml
9292

93+
executables:
94+
dbm-sqlite:
95+
source-dirs: sqlite/app
96+
ghc-options: -threaded -rtsopts "-with-rtsopts=-N"
97+
main: Main.hs
98+
dependencies:
99+
- HDBC-sqlite3
100+
- dbmigrations
101+
93102
tests:
94103
spec:
95104
source-dirs: tests
96105
ghc-options: -threaded -rtsopts "-with-rtsopts=-N"
97106
main: Spec.hs
98107
dependencies:
99-
- HDBC
100-
- HDBC-sqlite3
101108
- containers
102109
- dbmigrations
103110
- directory
@@ -109,3 +116,13 @@ tests:
109116
- template-haskell
110117
- text
111118
- time
119+
120+
sqlite-spec:
121+
source-dirs: sqlite/tests
122+
ghc-options: -threaded -rtsopts "-with-rtsopts=-N"
123+
main: Main.hs
124+
dependencies:
125+
- HDBC
126+
- HDBC-sqlite3
127+
- dbmigrations
128+
- hspec

sqlite/app/Main.hs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Main (main) where
2+
3+
import Prelude hiding (lookup)
4+
5+
import Database.HDBC.Sqlite3 (connectSqlite3)
6+
import Database.Schema.Migrations.Backend.HDBC (hdbcBackend)
7+
import Moo.Core
8+
import Moo.Main
9+
import System.Environment (getArgs)
10+
import System.Exit
11+
12+
main :: IO ()
13+
main = do
14+
args <- getArgs
15+
(_, opts, _) <- procArgs args
16+
loadedConf <- loadConfiguration $ _configFilePath opts
17+
case loadedConf of
18+
Left e -> putStrLn e >> exitFailure
19+
Right conf -> do
20+
let connectionString = _connectionString conf
21+
connection <- connectSqlite3 connectionString
22+
let
23+
backend = hdbcBackend connection
24+
parameters = makeParameters conf backend
25+
mainWithParameters args parameters
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{-# LANGUAGE DerivingVia #-}
22
{-# OPTIONS_GHC -Wno-orphans #-}
33

4-
-- | Use SQlite3 as an example to test the supplied 'hdbcBackend'
5-
module HDBCSpec
6-
( spec
7-
)
8-
where
4+
module Main (main) where
95

106
import Prelude
117

@@ -18,5 +14,8 @@ import Test.Hspec
1814

1915
deriving via (HDBCConnection Connection) instance BackendConnection Connection
2016

21-
spec :: Spec
22-
spec = before (connectSqlite3 ":memory:") $ after disconnect BackendTest.spec
17+
main :: IO ()
18+
main =
19+
hspec
20+
. before (connectSqlite3 ":memory:")
21+
$ after disconnect BackendTest.spec

src/Database/Schema/Migrations/Test/BackendTest.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ makeBootstrappedBackend conn = do
197197
-- backend does not support that.
198198
needDDL :: BackendConnection bc => (bc -> Expectation) -> bc -> Expectation
199199
needDDL f conn
200-
| supportsTransactionalDDL conn =
201-
pendingWith "Skipping due to lack of Transactional DDL"
202-
| otherwise = f conn
200+
| supportsTransactionalDDL conn = f conn
201+
| otherwise = pendingWith "Skipping due to lack of Transactional DDL"
203202

204203
ignoreSqlExceptions_ :: BackendConnection bc => bc -> IO a -> IO ()
205204
ignoreSqlExceptions_ conn act = void act `catch` pure ()

0 commit comments

Comments
 (0)