-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add TinyintTest that tests the special handling of tinyint(1)
- Loading branch information
Showing
4 changed files
with
35 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module TinyintTest where | ||
|
||
import Control.Monad.Trans.Except | ||
import Data.Text (Text) | ||
import Database.Persist.MySQL | ||
import Database.Persist.MySQL.Internal | ||
import Test.Hspec | ||
|
||
testCase :: Text -> IO (Either String (SqlType, Maybe Integer)) | ||
testCase t = runExceptT $ parseColumnType "tinyint" $ ColumnInfo | ||
{ ciColumnType = t | ||
, ciMaxLength = Nothing | ||
, ciNumericPrecision = PersistNull | ||
, ciNumericScale = PersistNull | ||
} | ||
|
||
specs :: Spec | ||
specs = describe "parseColumnType/tinyint" $ do | ||
it "parses tinyint as SqlOther \"tinyint\"" $ do | ||
result <- testCase "tinyint" | ||
result `shouldBe` Right (SqlOther "tinyint", Nothing) | ||
it "parses tinyint(1) as SqlBool" $ do | ||
result <- testCase "tinyint(1)" | ||
result `shouldBe` Right (SqlBool, Nothing) | ||
it "parses tinyint(4) as SqlOther \"tinyint\"" $ do | ||
result <- testCase "tinyint(4)" | ||
result `shouldBe` Right (SqlOther "tinyint", Nothing) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters