mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-25 08:24:00 +03:00
35 lines
1.6 KiB
Haskell
35 lines
1.6 KiB
Haskell
|
module Hasura.Backends.MSSQL.ErrorSpec (spec) where
|
||
|
|
||
|
import Hasura.Backends.MSSQL.SQL.Error
|
||
|
import Hasura.Prelude
|
||
|
import Test.Hspec
|
||
|
|
||
|
spec :: Spec
|
||
|
spec = do
|
||
|
it "test parseErrorClass all classes" $ mapM_ testParseErrorClass testCases
|
||
|
it "test parseErrorClass invalid SQLSTATE" $ (parseErrorClass "99999") `shouldBe` Nothing
|
||
|
where
|
||
|
testParseErrorClass :: (String, ErrorClass) -> Expectation
|
||
|
testParseErrorClass (sqlStateCode, expectedClass) =
|
||
|
(parseErrorClass sqlStateCode) `shouldBe` (Just expectedClass)
|
||
|
|
||
|
testCases :: [(String, ErrorClass)]
|
||
|
testCases =
|
||
|
[ ("22000", DataException NoSubclass),
|
||
|
("22001", DataException (Subclass StringDataRightTruncated)),
|
||
|
("22003", DataException (Subclass NumericValueOutOfRange)),
|
||
|
("22007", DataException (Subclass InvalidDatetimeFormat)),
|
||
|
("22008", DataException (Subclass DatetimeFieldOverflow)),
|
||
|
("22015", DataException (Subclass IntervalFieldOverflow)),
|
||
|
("22019", DataException (Subclass InvalidEscapeCharacter)),
|
||
|
("22025", DataException (Subclass InvalidEscapeSequence)),
|
||
|
("23000", IntegrityConstraintViolation),
|
||
|
("42000", SyntaxErrorOrAccessViolation NoSubclass),
|
||
|
("42S01", SyntaxErrorOrAccessViolation (Subclass TableOrViewAlreadyExists)),
|
||
|
("42S02", SyntaxErrorOrAccessViolation (Subclass TableOrViewNotFound)),
|
||
|
("42S11", SyntaxErrorOrAccessViolation (Subclass IndexAlreadyExists)),
|
||
|
("42S12", SyntaxErrorOrAccessViolation (Subclass IndexNotFound)),
|
||
|
("42S21", SyntaxErrorOrAccessViolation (Subclass ColumnAlreadyExists)),
|
||
|
("42S22", SyntaxErrorOrAccessViolation (Subclass ColumnNotFound))
|
||
|
]
|