2018-10-06 23:30:12 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module Gonito.ExtractMetadataSpec (spec) where
|
|
|
|
|
|
|
|
import Import
|
|
|
|
|
|
|
|
import qualified Data.Set as S
|
2018-11-03 10:56:58 +01:00
|
|
|
import qualified Data.Map.Strict as M
|
2018-10-06 23:30:12 +02:00
|
|
|
|
|
|
|
import Test.Hspec
|
2018-11-12 20:41:46 +01:00
|
|
|
import Gonito.ExtractMetadata (extractMetadataFromRepoDir, GonitoMetadata(..), ExtractionOptions(..), Link(..))
|
2018-10-06 23:30:12 +02:00
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = do
|
|
|
|
describe "extract metadata from repos" $ do
|
|
|
|
it "simple" $ do
|
|
|
|
extractMetadataFromRepoDir "test/fake-git-repos/simple/" def `shouldReturn` GonitoMetadata {
|
|
|
|
gonitoMetadataDescription = "Simple solution",
|
|
|
|
gonitoMetadataTags = S.fromList ["foo", "simple-solution", "baz"],
|
2018-11-12 20:41:46 +01:00
|
|
|
gonitoMetadataGeneralParams = M.empty,
|
|
|
|
gonitoMetadataExternalLinks = []
|
2018-10-06 23:30:12 +02:00
|
|
|
}
|
|
|
|
it "simple with some fields from the form" $ do
|
|
|
|
extractMetadataFromRepoDir "test/fake-git-repos/simple/" def {
|
|
|
|
extractionOptionsDescription = Just "Other solution",
|
2018-11-03 17:25:49 +01:00
|
|
|
extractionOptionsTags = Just $ S.fromList ["other-tag", "baz"]
|
2018-10-06 23:30:12 +02:00
|
|
|
} `shouldReturn` GonitoMetadata {
|
|
|
|
gonitoMetadataDescription = "Other solution",
|
|
|
|
gonitoMetadataTags = S.fromList ["foo", "simple-solution", "baz", "other-tag"],
|
2018-11-12 20:41:46 +01:00
|
|
|
gonitoMetadataGeneralParams = M.empty,
|
|
|
|
gonitoMetadataExternalLinks = []
|
2018-10-06 23:30:12 +02:00
|
|
|
}
|
|
|
|
it "with gonito.yaml" $ do
|
|
|
|
extractMetadataFromRepoDir "test/fake-git-repos/with-gonito-yaml/" def `shouldReturn` GonitoMetadata {
|
|
|
|
gonitoMetadataDescription = "Test solution",
|
|
|
|
gonitoMetadataTags = S.fromList ["zzz", "baz", "simple", "machine-learning"],
|
2018-11-03 10:56:58 +01:00
|
|
|
gonitoMetadataGeneralParams = M.fromList [("level", "4"),
|
2018-11-03 10:41:49 +01:00
|
|
|
("altitude", "8900.3"),
|
|
|
|
("q", "10.4"),
|
2018-11-12 20:41:46 +01:00
|
|
|
("style", "bold")],
|
|
|
|
gonitoMetadataExternalLinks = [
|
|
|
|
Link (Just "gitlab") "https://about.gitlab.com/",
|
|
|
|
Link (Just "Polish Wikipedia") "https://pl.wikipedia.org/wiki/Wikipedia:Strona_g%C5%82%C3%B3wna",
|
|
|
|
Link Nothing "https://tvtropes.org/" ]
|
2018-10-06 23:30:12 +02:00
|
|
|
}
|