import qualified Data.ByteString.Char8 as BS
import qualified Data.Text as T
import Test.Tasty (TestTree, defaultMain, testGroup)
import Test.Tasty.Golden (findByExtension, goldenVsString)
import System.FilePath (replaceExtension, takeBaseName, (<.>))
import Parser
import Deck.Diff
import Repr.DiffRep
main = defaultMain =<< goldenTests
goldenTests :: IO TestTree
goldenTests = do
deckfiles <- findByExtension [".decklist"] "test/golden"
return $ testGroup "Decklist to diff patch" $ do
deckPath <- deckfiles
let diffPath = replaceExtension deckPath ".diff"
return $
goldenVsString
(takeBaseName deckPath)
diffPath
( do
diffContent <- readDiffFiles deckPath (deckPath <.> "new")
let result = view . eval . uncurry diff <$> diffContent
diffAction = BS.fromStrict . BS.pack . T.unpack . fromRight' $ result
return diffAction
)