Separate tests into groups
Also test content of insert redirect
This commit is contained in:
@@ -9,26 +9,6 @@ import SpecHelper
|
||||
|
||||
import Network.HTTP.Types
|
||||
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.Aeson ((.:))
|
||||
import Control.Applicative ((<$>), (<*>))
|
||||
import Control.Monad (mzero)
|
||||
|
||||
data IncPK = IncPK {
|
||||
incId :: Int
|
||||
, incNullableStr :: Maybe String
|
||||
, incStr :: String
|
||||
, incInsert :: String
|
||||
} deriving (Show)
|
||||
|
||||
instance JSON.FromJSON IncPK where
|
||||
parseJSON (JSON.Object r) = IncPK <$>
|
||||
r .: "id" <*>
|
||||
r .: "nullable_string" <*>
|
||||
r .: "non_nullable_string" <*>
|
||||
r .: "inserted_at"
|
||||
parseJSON _ = mzero
|
||||
|
||||
spec :: Spec
|
||||
spec = around appWithFixture $ do
|
||||
describe "GET /" $ do
|
||||
@@ -92,19 +72,3 @@ spec = around appWithFixture $ do
|
||||
context "with response under server size limit" $
|
||||
it "returns whole range with status 200" $
|
||||
get "/auto_incrementing_pk" `shouldRespondWith` 206
|
||||
|
||||
describe "Posting new record" $
|
||||
context "into a table with auto-incrementing pk" $ do
|
||||
it "does not require pk in the payload" $
|
||||
post "/auto_incrementing_pk" [json|
|
||||
{ "non_nullable_string":"not null"} |]
|
||||
`shouldRespondWith` 201
|
||||
|
||||
it "links to the created resource" $
|
||||
post "/auto_incrementing_pk" [json|
|
||||
{ "non_nullable_string":"not null"} |]
|
||||
`shouldRespondWith` ResponseMatcher {
|
||||
matchBody = Nothing,
|
||||
matchStatus = 201,
|
||||
matchHeaders = [("Location", "/auto_incrementing_pk?id=eq.2")]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user