aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2021-08-14 22:26:24 +0200
committerDaniel Schadt <kingdread@gmx.de>2021-08-14 22:26:24 +0200
commit7ae86ad2f32994791edcd4d4ac4ec8499034181f (patch)
tree575f993a70de0c2cdd609b87ba7f3161a0b0df34 /test
parentc4ec73caf11acd7e2c1b3c28bfafc8c5cdb1fca2 (diff)
downloadCana-7ae86ad2f32994791edcd4d4ac4ec8499034181f.tar.gz
Cana-7ae86ad2f32994791edcd4d4ac4ec8499034181f.tar.bz2
Cana-7ae86ad2f32994791edcd4d4ac4ec8499034181f.zip
CGI: Use envvars to pass request URL
This is more conforming to other CGI environments, see for example [1] and [2]. This also allows us to easily add more fields in the future, for example to pass the remote address, the TLS certificate, the server version, ... [1]: https://en.wikipedia.org/wiki/Common_Gateway_Interface#Example [2]: https://sr.ht/~int80h/gemserv/
Diffstat (limited to 'test')
-rw-r--r--test/Cana/UtilSpec.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Cana/UtilSpec.hs b/test/Cana/UtilSpec.hs
index 7a3292a..2ccbf5b 100644
--- a/test/Cana/UtilSpec.hs
+++ b/test/Cana/UtilSpec.hs
@@ -25,3 +25,26 @@ spec = do
applyWhen True (+1) (3 :: Int) `shouldBe` 4
it "doesn't apply a function when False is given" $ do
applyWhen False (+1) (3 :: Int) `shouldBe` 3
+
+ describe "insert" $ do
+ it "works on an empty list" $ do
+ insert "foo" "bar" [] `shouldBe` [("foo", "bar")]
+ it "replaces an existing element" $ do
+ let i = insert "foo" "bar" [("a", "b"), ("foo", "baz"), ("c", "d")]
+ i `shouldContain` [("a", "b")]
+ i `shouldContain` [("foo", "bar")]
+ i `shouldContain` [("c", "d")]
+ length i `shouldBe` 3
+ it "inserts a missing element" $ do
+ let i = insert "foo" "bar" [("a", "b")]
+ i `shouldContain` [("a", "b")]
+ i `shouldContain` [("foo", "bar")]
+ length i `shouldBe` 2
+
+ describe "insertAll" $ do
+ it "inserts all elements" $ do
+ let i = insertAll [("foo", "bar"), ("qux", "baz")] [("a", "b"), ("foo", "gulp")]
+ i `shouldContain` [("foo", "bar")]
+ i `shouldContain` [("qux", "baz")]
+ i `shouldContain` [("a", "b")]
+ length i `shouldBe` 3