]> Git — Sourcephile - gargantext.git/blob - src-test/Utils/Crypto.hs
update: include the install command into start file
[gargantext.git] / src-test / Utils / Crypto.hs
1 {-|
2 Module : Utils.Crypto
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 module Utils.Crypto where
13
14 import Data.Text (Text)
15 import Test.Hspec
16
17 import Gargantext.Prelude
18 import Gargantext.Prelude.Crypto.Hash
19 import Gargantext.Prelude.Utils
20
21 -- | Crypto Hash tests
22 test :: IO ()
23 test = hspec $ do
24 describe "Hash String with frontend works" $ do
25 let text = "To hash with backend" :: Text
26 let hashed = "8a69a94d164279af2b7d1443ce08da6184b3d7e815406076e148159c284b53c3" :: Hash
27 -- ^ hash from fronted with text above
28 it "compare" $ do
29 hash text `shouldBe` hashed
30
31 describe "Hash List with backend works" $ do
32 let list = ["a","b"] :: [Text]
33 let hashed = "ab19ec537f09499b26f0f62eed7aefad46ab9f498e06a7328ce8e8ef90da6d86" :: Hash
34 -- ^ hash from frontend with text above
35 it "compare" $ do
36 hash list `shouldBe` hashed
37
38 ------------------------------------------------------------------------
39 -- | TODO property based tests
40 describe "Hash works with any order of list" $ do
41 let hash1 = hash (["a","b"] :: [Text])
42 let hash2 = hash (["b","a"] :: [Text])
43 it "compare" $ do
44 hash1 `shouldBe` hash2