Basic hspec + postgres fixtures setup
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
module PgQuerySpec where
|
||||
|
||||
import Test.Hspec
|
||||
|
||||
import Database.HDBC
|
||||
import Database.HDBC.PostgreSQL
|
||||
|
||||
loadFixture :: String -> IO ()
|
||||
loadFixture name = do
|
||||
sql <- readFile $ "test/fixtures/" ++ name ++ ".sql"
|
||||
conn <- connectPostgreSQL "postgres://postgres:@localhost:5432/dbapi_test"
|
||||
runRaw conn sql
|
||||
commit conn
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
hspec spec
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll (loadFixture "schema") $ do
|
||||
describe "insert" $
|
||||
it "can insert into an empty table" $
|
||||
head [23 ..] `shouldBe` (23 :: Int)
|
||||
|
||||
describe "insert again" $
|
||||
it "is true" $
|
||||
True `shouldBe` True
|
||||
@@ -0,0 +1 @@
|
||||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
||||
Vendored
+105
@@ -0,0 +1,105 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 9.3.4
|
||||
-- Dumped by pg_dump version 9.3.1
|
||||
-- Started on 2014-08-10 15:29:43 PDT
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SET check_function_bodies = false;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
--
|
||||
-- TOC entry 172 (class 3079 OID 12018)
|
||||
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 2209 (class 0 OID 0)
|
||||
-- Dependencies: 172
|
||||
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||
|
||||
|
||||
SET search_path = public, pg_catalog;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_with_oids = false;
|
||||
|
||||
--
|
||||
-- TOC entry 171 (class 1259 OID 226379)
|
||||
-- Name: auto_incrementing_pk; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE auto_incrementing_pk (
|
||||
id integer NOT NULL,
|
||||
nullable_string character varying,
|
||||
non_nullable_string character varying NOT NULL,
|
||||
inserted_at timestamp with time zone DEFAULT now()
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 170 (class 1259 OID 226377)
|
||||
-- Name: auto_incrementing_pk_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE auto_incrementing_pk_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 2210 (class 0 OID 0)
|
||||
-- Dependencies: 170
|
||||
-- Name: auto_incrementing_pk_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE auto_incrementing_pk_id_seq OWNED BY auto_incrementing_pk.id;
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 2090 (class 2604 OID 226382)
|
||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY auto_incrementing_pk ALTER COLUMN id SET DEFAULT nextval('auto_incrementing_pk_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 2211 (class 0 OID 0)
|
||||
-- Dependencies: 170
|
||||
-- Name: auto_incrementing_pk_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('auto_incrementing_pk_id_seq', 1, true);
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 2093 (class 2606 OID 226388)
|
||||
-- Name: auto_incrementing_pk_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY auto_incrementing_pk
|
||||
ADD CONSTRAINT auto_incrementing_pk_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
-- Completed on 2014-08-10 15:29:43 PDT
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user