From 17915c8486c9a9a91f3e29ad396b605c2c0029f0 Mon Sep 17 00:00:00 2001 From: Peter Hajdu Date: Fri, 22 May 2020 15:37:50 +0200 Subject: [PATCH] handle ioexceptions in createfiledestination --- test/Bobek/Test/FileEnvTest.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/Bobek/Test/FileEnvTest.hs b/test/Bobek/Test/FileEnvTest.hs index 07c4409..206368d 100644 --- a/test/Bobek/Test/FileEnvTest.hs +++ b/test/Bobek/Test/FileEnvTest.hs @@ -1,7 +1,7 @@ module Bobek.Test.FileEnvTest (fileEnvSpec) where import Bobek.Destination (PublishResult (..)) -import Bobek.FileEnv (createFileSource, readFromFile, serializeMessage, writeToFile) +import Bobek.FileEnv (createFileDestination, createFileSource, readFromFile, serializeMessage, writeToFile) import Bobek.Message (Message (..)) import Bobek.ReceiveId (ReceiveId (..)) import Bobek.Source (NoMessageReason (..)) @@ -56,3 +56,8 @@ fileEnvSpec = $ do (Left err) <- createFileSource "hopefullynonexistentfile" err `shouldBe` "hopefullynonexistentfile: openFile: does not exist (No such file or directory)" + describe "createfiledestination" + $ it "should handle io errors during file open" + $ do + result <- createFileDestination "/hopefullynonexistentfile" + isLeft result `shouldBe` True