Skip to content
Snippets Groups Projects
Spec.hs 1.06 KiB
Newer Older
{-# LANGUAGE OverloadedStrings #-}
module Main ( main ) where

import           Data.ByteString           (fromStrict)
import           Data.Map                  (Map)
import           Data.Text.Encoding        (encodeUtf8)
import           Dhall                     (auto, embed, inject, input)
import           Dhall.Pretty              (layout, prettyExpr)
import           Horizon.Spec              (HsPkg)
import           Prettyprinter.Render.Text (renderStrict)
import           Test.Tasty                (TestTree, defaultMain, testGroup)
import           Test.Tasty.Golden         (goldenVsString)

main :: IO ()
main = defaultMain tests

tests :: TestTree
tests = testGroup "Tests" [ samplePackageSet ]

samplePackageSet :: TestTree
samplePackageSet = goldenVsString "sample package set" "./test/data/sample-package-set/output.dhall" $ do
                    (x :: Map String HsPkg) <- input auto "./test/data/sample-package-set/input.dhall"
                    let doc = prettyExpr $ embed inject x
                    pure $ fromStrict $ encodeUtf8 $ renderStrict (layout doc)