File: ClassSpec.hs

package info (click to toggle)
haskell-persistent 2.17.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,196 kB
  • sloc: haskell: 14,076; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Database.Persist.ClassSpec where

import Data.Time
import Database.Persist.Class
import Database.Persist.Types
import Test.Hspec

spec :: Spec
spec = describe "Class" $ do
    describe "PersistField" $ do
        describe "UTCTime" $ do
            it "fromPersistValue with ISO8601 format including UTC timezone Z (canonical)" $
                fromPersistValue (PersistText "2018-02-27T10:49:42.123Z")
                    `shouldBe` Right
                        (UTCTime (fromGregorian 2018 02 27) (timeOfDayToTime (TimeOfDay 10 49 42.123)))
            it "fromPersistValue with ISO8601 format no timezone (backwards-compatibility)" $
                fromPersistValue (PersistText "2018-02-27T10:49:42.123")
                    `shouldBe` Right
                        (UTCTime (fromGregorian 2018 02 27) (timeOfDayToTime (TimeOfDay 10 49 42.123)))
            it "fromPersistValue with pretty format (backwards-compatibility)" $
                fromPersistValue (PersistText "2018-02-27 10:49:42.123")
                    `shouldBe` Right
                        (UTCTime (fromGregorian 2018 02 27) (timeOfDayToTime (TimeOfDay 10 49 42.123)))