From 2836f615224a3a7fbd4b09b79a4d960b0d6f0eeb Mon Sep 17 00:00:00 2001 From: Ashley Stacey Date: Wed, 21 Aug 2019 11:17:25 +1000 Subject: [PATCH] [#500] Trails-tests: Randomise GS1 Company Prefix. --- projects/trails/test/Mirza/Trails/Tests/Client.hs | 7 ++++++- projects/trails/trails.cabal | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/trails/test/Mirza/Trails/Tests/Client.hs b/projects/trails/test/Mirza/Trails/Tests/Client.hs index 7a82aeed..7f5f226d 100644 --- a/projects/trails/test/Mirza/Trails/Tests/Client.hs +++ b/projects/trails/test/Mirza/Trails/Tests/Client.hs @@ -30,10 +30,14 @@ import qualified Network.HTTP.Types.Status as NS import Servant.API.ContentTypes import Servant.Client +import System.Random + import Control.Exception (bracket) import Control.Monad import Data.Either (isLeft, isRight) +import Data.Foldable import Data.List +import Data.Text (pack) import Data.Time.Clock import Data.UUID import Data.UUID.V4 @@ -363,9 +367,10 @@ buildEntry :: IO TrailEntry buildEntry = do time <- liftIO getCurrentTime uuid <- liftIO nextRandom + prefix <- pack <$> (sequence $ take 7 $ repeat $ randomRIO ('0', '9')) let unsignedEntry = TrailEntry 1 (EntryTime time) - (GS1CompanyPrefix "0000001") -- TODO: Should randomise this. + (GS1CompanyPrefix prefix) (EventId uuid) [] (SignaturePlaceholder "") diff --git a/projects/trails/trails.cabal b/projects/trails/trails.cabal index c4fc466c..c8e6757a 100644 --- a/projects/trails/trails.cabal +++ b/projects/trails/trails.cabal @@ -102,12 +102,14 @@ test-suite trails-test , http-types , katip , mtl + , random , servant , servant-client , servant-client-core , tasty , tasty-hunit , temporary + , text , time , uuid default-language: Haskell2010