diff options
author | Daniel Schadt <kingdread@gmx.de> | 2021-08-03 17:46:33 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2021-08-03 17:46:33 +0200 |
commit | c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2 (patch) | |
tree | a6b83bf2faf151b31489862a271f60a0942f587d | |
parent | ace37a9df956828634c94637d621180002a7920c (diff) | |
download | Cana-c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2.tar.gz Cana-c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2.tar.bz2 Cana-c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2.zip |
add basic tests for renderResponse & parseResponse
-rw-r--r-- | test/Cana/ProtocolSpec.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Cana/ProtocolSpec.hs b/test/Cana/ProtocolSpec.hs new file mode 100644 index 0000000..6effd25 --- /dev/null +++ b/test/Cana/ProtocolSpec.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE OverloadedStrings #-} +module Cana.ProtocolSpec where + +import Cana.Protocol +import Test.Hspec + +spec :: Spec +spec = do + describe "renderResponse" $ do + it "correctly renders a success response" $ do + let response = GeminiResponse + { responseStatus = codeSuccess + , responseMeta = "text/gemini" + , responseData = "# Hello World!" + } + wanted = "20 text/gemini\r\n# Hello World!" + renderResponse response `shouldBe` wanted + + describe "parseResponse" $ do + it "correctly parses a success response" $ do + let response = GeminiResponse + { responseStatus = codeSuccess + , responseMeta = "text/gemini" + , responseData = "# Hello World!" + } + wanted = "20 text/gemini\r\n# Hello World!" + parseResponse wanted `shouldBe` Just response |