repos / handle-examples.hs.git


handle-examples.hs.git / records-handle / test-impl
Evgenii Akentev  ·  2021-01-05

TestWeatherProvider.hs

 1module TestWeatherProvider where
 2
 3import WeatherProvider
 4
 5-- | This is a configuration that allows to setup the provider for tests.
 6data Config = Config
 7  { initTemperature :: Temperature
 8  }
 9
10new :: Config -> Handle
11new config = Handle
12  { getWeatherData = getTestWeatherData $ initTemperature config
13  }
14
15-- | This is an implementation `WeatherProvider` interface for tests
16getTestWeatherData :: Int -> Location -> Day -> IO WeatherData
17getTestWeatherData temp _ _ = return $ WeatherData temp