-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHGistTest.hs
38 lines (32 loc) · 1.36 KB
/
HGistTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-# LANGUAGE OverloadedStrings #-}
import Test.HUnit
import HGist (Gist(..), File(..), decodeGistList, showGist, encodeGist, gitHubUrl)
import qualified Data.ByteString.Lazy.Char8 as BL
tests = test [
"(decodeGistList)" ~:
[Gist {gistId = "1",
description = Just "My description",
files = [ File {filename = "myfile.hs"}]}]
~=?
decodeGistList "[{\"id\": \"1\", \"description\": \"My description\", \"files\": {\"myfile.hs\": {\"filename\": \"myfile.hs\"}}}]",
"(decodeGistList No description)" ~:
[Gist {gistId = "2",
description = Nothing,
files = [ File {filename = "myfile.hs"}]}]
~=?
decodeGistList "[{\"id\": \"2\", \"description\": null , \"files\": {\"myfile.hs\": {\"filename\": \"myfile.hs\"}}}]",
"(showGist)" ~:
"3: My description\n myFile.hs, myOtherFile.hs"
~=?
showGist Gist {
gistId = "3",
description = Just "My description",
files = [File {filename = "myFile.hs"}, File {filename = "myOtherFile.hs"}]},
"(encodeGist)" ~:
"{\"files\":{\"first-file\":{\"content\":\"first content\"}},\"description\":\"my description\",\"public\":true}"
~=?
(BL.unpack $ encodeGist "my description" [("first-file", "first content")]),
"(url)" ~:
"https://api.github.com/foo/bar" ~=? gitHubUrl ["foo", "bar"]
]
main = runTestTT tests