aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2021-08-03 17:46:33 +0200
committerDaniel Schadt <kingdread@gmx.de>2021-08-03 17:46:33 +0200
commitc4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2 (patch)
treea6b83bf2faf151b31489862a271f60a0942f587d
parentace37a9df956828634c94637d621180002a7920c (diff)
downloadCana-c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2.tar.gz
Cana-c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2.tar.bz2
Cana-c4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2.zip
add basic tests for renderResponse & parseResponse
-rw-r--r--test/Cana/ProtocolSpec.hs27
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