File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
tests/NumberSix/Handlers/Weather Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 2
2
{-# LANGUAGE OverloadedStrings #-}
3
3
module NumberSix.Handlers.Weather
4
4
( handler
5
- , get_weather
5
+ , getWeather
6
6
, Weather (.. )
7
7
, Temperature (.. )
8
8
) where
@@ -75,8 +75,8 @@ instance Show Description where
75
75
76
76
77
77
--------------------------------------------------------------------------------
78
- get_weather :: Text -> IO (Maybe Weather )
79
- get_weather query = do
78
+ getWeather :: Text -> IO (Maybe Weather )
79
+ getWeather query = do
80
80
result <- ((parseJsonEither <$> http url id ) :: IO (Either String Weather ))
81
81
`catch` (\ ex -> return $ Left $ show (ex :: HttpException ))
82
82
either (const $ return Nothing ) (return . Just ) result
@@ -88,7 +88,7 @@ get_weather query = do
88
88
--------------------------------------------------------------------------------
89
89
weather :: Text -> IO Text
90
90
weather query = do
91
- result <- get_weather query
91
+ result <- getWeather query
92
92
maybe randomError (return . pprint) result
93
93
where
94
94
pprint :: Weather -> Text
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module NumberSix.Handlers.Weather.Tests
6
6
7
7
8
8
--------------------------------------------------------------------------------
9
- import Data.Maybe (fromJust , isJust )
9
+ import Data.Maybe (fromJust )
10
10
import Test.Framework (Test , testGroup )
11
11
import Test.HUnit (assert )
12
12
@@ -22,8 +22,7 @@ tests :: Test
22
22
tests = testGroup " NumberSix.Handlers.Weather.Tests"
23
23
[ cases " weather"
24
24
[ do
25
- result <- get_weather " gent"
26
- assert $ isJust result
25
+ result <- getWeather " gent"
27
26
let (Weather (Temperature t) _) = fromJust result
28
27
assert $ - 15 <= t && t <= 60
29
28
]
You can’t perform that action at this time.
0 commit comments