@@ -1,10 +1,9 @@
1−{-# LANGUAGE QuasiQuotes #-}
1+{-# LANGUAGE OverloadedStrings #-}
2module Data.Yaml.IncludeSpec (main, spec) where
2module Data.Yaml.IncludeSpec (main, spec) where
4import Test.Hspec
4import Test.Hspec
5import Data.List (isPrefixOf)
5import Data.List (isPrefixOf)
6import Data.Aeson
6import Data.Aeson
8import Data.Yaml (ParseException(InvalidYaml))
7import Data.Yaml (ParseException(InvalidYaml))
9import Data.Yaml.Include
8import Data.Yaml.Include
10import Text.Libyaml (YamlException(YamlException))
9import Text.Libyaml (YamlException(YamlException))
@@ -12,28 +11,33 @@ import Text.Libyaml (YamlException(YamlException))
12main :: IO ()
11main :: IO ()
13main = hspec spec
12main = hspec spec
15spec :: Spec
17spec :: Spec
17 describe "decodeFile" $ do
19 describe "decodeFile" $ do
18 it "supports includes" $ do
20 it "supports includes" $ do
19− decodeFile "test/resources/foo.yaml" `shouldReturn` Just [aesonQQ|
21+ decodeFile "test/resources/foo.yaml" `shouldReturn` Just (object
21− foo: 23,
22+ [ "foo" .= asInt 23
22− bar: {one: 1, two: 2},
24+ [ "one" .= asInt 1
23− baz: 42
27+ , "baz" .= asInt 42
27 it "supports recursive includes" $ do
30 it "supports recursive includes" $ do
28− decodeFile "test/resources/baz.yaml" `shouldReturn` Just [aesonQQ|
31+ decodeFile "test/resources/baz.yaml" `shouldReturn` Just (object
30− foo: {
32+ [ "foo" .= object
31− foo: 23,
33+ [ "foo" .= asInt 23
32− bar: {one: 1, two: 2},
35+ [ "one" .= asInt 1
33− baz: 42
38+ , "baz" .= asInt 42
38 it "aborts on cyclic includes" $ do
42 it "aborts on cyclic includes" $ do
39 (decodeFile "test/resources/loop/foo.yaml" :: IO (Maybe Value)) `shouldThrow` anyException
43 (decodeFile "test/resources/loop/foo.yaml" :: IO (Maybe Value)) `shouldThrow` anyException