From 7ae86ad2f32994791edcd4d4ac4ec8499034181f Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 14 Aug 2021 22:26:24 +0200 Subject: 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/ --- test/Cana/UtilSpec.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') 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 -- cgit v1.2.3