packages feed

phino-0.0.0.52 / test / YamlSpec.hs

-- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com-- SPDX-License-Identifier: MITmodule YamlSpec whereimport Control.Exception (Exception (displayException), SomeException)import Control.Monadimport Data.List (isInfixOf)import Miscimport System.FilePathimport Test.Hspec (Spec, describe, it, runIO, shouldReturn, shouldThrow)import Yaml (yamlRule)spec :: Specspec = do  describe "parses yaml rule" $ do    let resources = "test-resources/yaml-packs"    packs <- runIO (allPathsIn resources)    forM_      packs      ( \pth -> it (makeRelative resources pth) $ do          _ <- yamlRule pth          pure () `shouldReturn` ()      )  describe "fails on yaml typos" $ do    let resources = "test-resources/yaml-typos"    packs <- runIO (allPathsIn resources)    forM_      packs      ( \pth ->          it (makeRelative resources pth) $            shouldThrow              (yamlRule pth)              ( \e ->                  let msg = displayException (e :: SomeException)                   in "Unknown" `isInfixOf` msg || "Exactly one" `isInfixOf` msg              )      )