-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checkpoint testing and preparing for cabal parsing.
- Loading branch information
Showing
11 changed files
with
125 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
module Initialise | ||
( Initialise, | ||
runInitialise, | ||
relativePath, | ||
replaceIf, | ||
replace, | ||
) | ||
where | ||
|
||
import Configuration (Configuration) | ||
import Control.Monad.Reader (ReaderT, runReaderT) | ||
import GHC.IO.Encoding (TextDecoder) | ||
|
||
type Initialise = ReaderT MetaData IO | ||
type Initialise = ReaderT Configuration IO | ||
|
||
runInitialise :: Initialise () -> IO () | ||
runInitialise :: Initialise () -> Configuration -> IO () | ||
runInitialise = runReaderT | ||
|
||
contents :: FilePath -> Initialise Text | ||
contents path = undefined |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module CabalGolden (golden) where | ||
|
||
import Data.Maybe (fromJust) | ||
import qualified Defaults as SUT | ||
import Network.URI (parseURI) | ||
import Test.Hspec (Spec, describe, it, shouldBe) | ||
import Test.Tasty (TestTree) | ||
import Test.Tasty.Golden (TestTree) | ||
|
||
golden :: IO TestTree | ||
golden = | ||
testGroup "Cabal" $ | ||
testGroup "convert" . map convertTest <$> findByExtension [".cabal"] d | ||
where | ||
d = normalise "test/initialise/data" | ||
|
||
convertTest :: FilePath -> TestTree | ||
convertTest path = goldenVsStringDiff name diff golden action | ||
where | ||
name = takeBaseName path | ||
diff golden output = ["diff", "-u", golden, output] | ||
golden = path `replaceExtension` ".golden.cabal" | ||
action = SUT.convert =<< SUT.contents path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module MetaDataSpec (spec) where | ||
|
||
import qualified MetaData as SUT | ||
import Options.Applicative (execParserPure) | ||
import Test.Hspec (Spec, describe, it) | ||
|
||
spec :: Spec | ||
spec = | ||
describe "MetaData" $ do | ||
describe "parser" $ do | ||
it "should error if homepage isn't a URI" $ do | ||
(error, exitCode) <- | ||
renderFailure | ||
<$> execParserPure | ||
defaultPrefs | ||
(info (SUT.parser defaults <**> helper)) | ||
["--homepage", "not-a-url"] | ||
exitCode `shouldNotBe` 0 | ||
error `shouldBe` "" | ||
it "should error if licence isn't an SPDX licence ID" $ do | ||
(error, exitCode) <- | ||
renderFailure | ||
<$> execParserPure | ||
defaultPrefs | ||
(info (SUT.parser defaults <**> helper)) | ||
["--licence", "not-a-licence"] | ||
exitCode `shouldNotBe` 0 | ||
error `shouldBe` "" | ||
|
||
defaults :: SUT.Defaults | ||
defaults = | ||
SUT.Defaults | ||
{ SUT.dOrigin = fromJust (parseURI "http://github.com/username/repository.git"), | ||
SUT.dAuthor = "Forename Surname", | ||
SUT.dMaintainer = "[email protected]", | ||
SUT.dPath = ".", | ||
SUT.dYear = 1970 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,6 @@ import qualified Defaults as SUT | |
import Network.URI (parseURI) | ||
import Test.Hspec (Spec, describe, it, shouldBe) | ||
|
||
defaults :: SUT.Defaults | ||
defaults = | ||
SUT.Defaults | ||
{ SUT.dOrigin = fromJust (parseURI "http://github.com/username/repository.git"), | ||
SUT.dAuthor = "Forename Surname", | ||
SUT.dMaintainer = "[email protected]", | ||
SUT.dPath = ".", | ||
SUT.dYear = 1970 | ||
} | ||
|
||
spec :: Spec | ||
spec = describe "Defaults" $ do | ||
describe "dName" $ do | ||
|
@@ -36,3 +26,13 @@ spec = describe "Defaults" $ do | |
SUT.dPath = "/workspaces/template.hs", | ||
SUT.dYear = 2023 | ||
} | ||
|
||
defaults :: SUT.Defaults | ||
defaults = | ||
SUT.Defaults | ||
{ SUT.dOrigin = fromJust (parseURI "http://github.com/username/repository.git"), | ||
SUT.dAuthor = "Forename Surname", | ||
SUT.dMaintainer = "[email protected]", | ||
SUT.dPath = ".", | ||
SUT.dYear = 1970 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module InitialiseSpec (spec) where | ||
|
||
import Test.Hspec (Spec, describe) | ||
|
||
spec :: Hspec | ||
spec = describe "Initialise" $ do | ||
undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters